So you issue is that when only one is selected the other input has a value of NULL. This is resulting in an error because
I assume that you probably are not actually looking for nulls
You can not use the == operator for NULL values. As a test see what you get when you put NULL == NULL in your console. You need to use is.null() to test for whether a value is or isn't a NULL.
I would recommend that you put some logic in your server code that handles the different cases. For example, you could do this:
You can add further logic to handle other cases. As a note, you do not need to use the & operator in dplyr's filter function as comma separated arguments are automatically handled in that manner.
As for needing both & and | functionality, I would recommend adding an input so the user can choose (If that's what you want) and add more logic similar to above so that different filtering operations are happening based on what the user wants.
If your question's been answered, would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it: