I'll wear my Phillies hat in any of the lax locations.
However, in the signature locations with the 'suggested' dress code, I will remove my hat (not have one on after getting ready for dinner or else I'd have a blown out cal-lick and hat hair).
Hats were historically considered 'dirty' and full of the outside elements, they were to cover the head. So leaving an item on associated with a lack of cleanliness, is clearly frowned upon. Sweat bands in the hat, 'hat smell', etc.
I don't look beyond the general courtesy of removing my hat, because then it gets subjective. I remove my hat, but is it really more unbecoming that the woman in a dress who hasn't shaved her underarms in six years and I can see hairs curling out the side? But hey, she 'meets the dress code' ... Or that open-toed shoes are welcomed, but someone's yellow calcified eagle talons twisted and contorted are 'acceptable', but not a hat...
Better to not over-analyze lol.