The code didn't work because the second inverted "Enemy has LOS to player" condition also was picking enemy instances. So it worked like this:
Are there any enemies which see the player? set var to 1
Are there any enemies which don't see the player? set var to 0
Since all events run from top to bottom, the second event was resetting the variable.