We have already discussed this in the Security forum, and you have been told that this an application error, and that you need to find the programmer who wrote the code, or contact the vendor of this is a vendor app.
It's great that you post the code this time, but the problem is with the data. It could be the programmer put in an incorrect check, but it could also indicate that you have bad data.
In any case, resolving this problem is far beyond the capabilities of this forum.
Why do ask here, rather than locally? What is your role in your organisation?
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se