My wife’s favorite sopranos episode included the scene where Tony was upset because some hid had on a ball cap at a nearby table. He got up and told him take off the hat. Guy stared back where upon his date apparently recognizing the dange said take off the hat. He did. Tony then sent over a nice bottle of wine.
I won’t wear any cap or hat while eating indoors. My parents would have slapped any of us out from underneath a cap worn at the table, and those old lessons stuck.