It never fails to amaze me how a seemingly innocent question/comment will stir up all kinds of emotions ;D
I was brought up in a far-off land where it was considered both appropriate and good manners to remove one's cap/hat when entering someone's home, a church/chapel, a school, a place of work, a restaurant and various other establishments. It was also common practice to tip one's hat when meeting a lady. However, folks didn't wear baseball caps and were more likely to wear either a Trilby (see
here) or a cloth cap (aka Dai cap), like you might see the English country squire wear in his convertible (see
here).
Our last home for 14 years was in a small, but growing, California wine country/rodeo town where, at the local bar and grill, all the guys and gals wore western hats and nobody thought anything about it.
Here on the CA Delta, if we go to a traditional family restaurant/diner, folks wear caps or hats. If I stop by Pete's, a bar/cafe on one of the Delta Levees, most of the patrons are Mexican farm workers and they'll likely be wearing work hats (kinda like a straw western hat).
Maybe it was my upbringing but, if I enter a restaurant wearing a cap or hat, I'll automatically head straight to the head (men's room), remove the cap/hat and do a little grooming. It's not necessarily something I do consciously, more likely on autopilot. But I'm always conscious that I might lose the darn thing when I try to balance it on my knee or place it on adjacent chair.
Bottom line for me is that I go along with whatever is customary in a particular establishment/community and I won't consciously step out of line where a "dress code" is observed.
BTW next time you see Shayne's orange baseball cap (and it really is orange and can be spotted a mile away), shout out "here comes the CalTrans road crew". Don't be surprised to find a real nice guy under the cap.