This is because the attack roll dictates whether it is a hit or not, not the damage roll (see Player's manual p. 194 in the section on Rolls of attack):
When you make an attack, your attack roll determines whether the attack hits or misses.
The attack jet occurs before rolling damage and determines if you hit. This is to say that at the moment you get damage, the attack roll will have already resulted in a shot or a misfire. If this resulted in a hit, it is always considered a hit, even if the resulting damage ends up being 0 when calculated later due to damage resistance, damage immunity, damage threshold ( see Dungeon Master Guide for this obscure property), or what you have.
Note that many attack-responsive features use a different formulation. A feature that triggers "when you're hit / hit" and a feature that fires "when you're damaged / when you do damage" is not quite the same. The type of "touch" feature would be triggered even if the damage was 0, while the "damage" type would only trigger if the damage was equal to or greater than 1. Therefore, be careful when doing damage. evaluation of such a feature.