Theres a utility in AI.qc I believe its called () Visible. It also checks for water / waterlevel, which may be a better choice than your Traceline code. If you are using DP, also be aware of the built in () CheckPVS which may or may not be better than Checkclient ().
Where you commented "Got One", I would put in possibly: eprint (client); , which will tell you for sure what it is because if your option entity is world, the tracelines will always fai. Move that eprint around to different locations and run the same scenario some mre time if need be to get a better idea of whats going on. If all seems ok, then something else in other code is altering one of your entities possibly.