The state mask wasnt applied before comparison giving false results. It shouldnt really happen that a ray state contains any flags that need to be masked away, but if it does happen its better to not get stuck.