tsan: refactor overly-complex logical condition