It would take a very complex calculation to merge the logic from the two. You are talking about 9 different combinations of values that have to become terms in your calculation.
For every given term in the first calculation, you have to evaluate all three possibilities shown in the the second.
Items is the parent table, and Settings the table seen in two separate portals? Is the relationship between Items and the two portals the same TO?
If so, and you want to see items from both portals, combined into a single portal, then I think you just need to OR the two conditions. Enclose the two clauses in parentheses and put OR between them. Btw, I see some missing parentheses in the first condition (around the AND condition).
This is what I was worried about
Settings table is just a preference table with global values used for different menu items and is connected by cartesian with 1 record, I think this is a common approach? I also had already tried exactly what you said about or between and parentheses the first condition, but with no results. I will try again.