"Grammatically correct" generally means "follows certain normative rules", such as set forth in Strunk & White. This "subjunctive" form is dying out in actual speech, so you will encounter a range of uses and opinions, depending on who you ask. If you say something like "Had I known about the train, I would have left earlier", you will mark yourself as "talking funny". You could get away with it in a formal lecture, but not if you're just chatting with your mates at the local, or having a beer with friends at the bar. It is most-dead in the US, among the young. OTOH, *"Have I known about the train,...." is just plain and universally ungrammatical. If you use it, you're socially expected to use it correctly, following those normative rules (whatever they are). Your shirt example is a good example of people making stuff up – hyper-rationalizing.
IMO it is most productive to focus on classical conditional contexts – the difference between "If he had dug a hole" vs. "If he dug a hole" or "If he has dug a hole"; "If he were rich" vs. "If he was rich" or "If he is rich". For me, "If he has dug a hole, he would be covered in dirt" is not quite ungrammatical, but I really don't like it. But I suspect that the kids on the corner talk that way. If your goal is to emulate a certain social class, e.g. The Posh (of England), then you probably need a Posh tutor. I believe that if you can get the had/has difference figured out in this context (actual conditionals), you might be able to apply that to the other contexts where "if" is used.