I assume that “var” actually represents a bunch of different variables? Might be clearer for examples like this if you differentiate them e.g. (var1=true) and (var2=false).
I think what you’ve got there is in danger of triggering if the last variable is “both”, regardless of what’s happening with the other variables. For what you describe, I suspect this would work better:
*if ((var1 = false) and (var2 = true)) and ((var3 = “female”) or (var3 = “both”))
Note that if var3 is a sexual orientation variable with three possible values (male, female, or both), you could more simply use (var3 != “male”) instead of =“female” or =“both”. The exclamation point means not, i.e. var3 is not equal to male.
Have a look at this post for a walkthrough of a mixed or/and condition: