...Ok to put on hat after you get your food.
Impolite for a man to wear a hat inside
Unless you are under arms. A military exception, but I like it.
A few years back, an elderly gentleman related a story about visiting his old school. He said he was dismayed to see so many men wearing caps indoors, when picking up their kids. I didn’t broach the subject of how many of those men were the fathers of bastards, or cohabiting with the kid’s mom without benefit of marriage. Those stats would have stroked him out.