PKHeX does its best to tell what's legal and what's not. Most of PKHeX checks are far way better than Home/GF official checks, but keep in mind that there could be false positives and that legality checks can be improved over time. If you want to check details of how the legality checker works, you should take a look at the PKHeX source code.
However, the Golden rule is to never edit a Pokémon that has already been in HOME and that is outside of its game of origin.
PKHeX can not check the Home server side data.
If you want to be certain of a mon legality, either do not generate or edit them, or comprehend how the inner game mechanics works.
What Home detect as illegal can't be deposited anyways.
Check the Home tracker post for more info: