Using OR with predefines

I want to use the following condition:

{#agreement^costs= ‘party1’ OR ‘party2’: (…) | = ‘joint’: (…)}

If the user clicks on “party1” or “party2”, the same sentence needs to appear in the contract. For “joint”, another sentence needs to appear.

However, in the contract, the second part of the condition doesn’t work and it always provides the text of “party1” or “party2”, even if I click on “joint”.

Did I make a mistake in my condition?

This is a common mistake. As a human being, you probably read this is as (#agreement^costs = "party1") OR (#agreement^costs = "party2"), because this makes most sense. Computers, however, read this as (#agreement^costs = "party1") OR ("party2"). In a next step, the ("party2")is then considered equal to true, because any text-value that is not empty is considered equal to true. So the end result is that this will always be equal to true, which is definitely not what you want.

Like combinations of additions/subtractions/multiplications/divisions in mathematics (where 1 + 2 * 3 is equal to 7 and not 9), combinations of AND/OR/NOT follow certain rules regarding the order of precedence: is a OR b AND c OR d equal to (a OR b) AND (c OR d), or instead a OR (b AND C) or d, or even something else?

However, the rules of precedence are not well-known, and quite confusing — and even if you know the rules, you can be almost certain that whoever comes after you will not know them. The easiest approach is therefore to simply put parentheses — this way, you can be sure that everything is correct.