The problem is that constant WHERE condition (the subquery) evaluates incorrectly to 0 in optimize_cond (in the SELECT list the subquery returns correct result - TRUE).
The problem is that constant WHERE condition (the subquery) evaluates incorrectly to 0 in optimize_cond (in the SELECT list the subquery returns correct result - TRUE).