How to filter entries by tags array using ['or'] and by category not using or
The relatedTo function accepts multiple different formats. If you want to search for Elements that are related to a list of categories and a list of tags you can do that like this

relatedTo([
    'and',
    ['element' =&gt; [1, 2, 3]],
    ['element' =&gt; [4, 5, 6]]
]);


This will return you all Elements that are related to the first array and related to the second array. So you goal should be to create an array of category IDs and Tag IDs and pass them together in the relatedTo

To get Elements that are related to all elements of one array and a single one from another array do the following

relatedTo([
    'and',
    ['element' =&gt; [1, 2, 3]],
    ['element' =&gt; ['and', 4, 5, 6]]
]);