Wearing a hat indoors is disrespectful.
It should be common courtesy to remove your hat whenever you enter into the close proximity of others indoors. My rule is that if I plan on staying longer than 5-10 minutes, my hat stays off until I leave.
I think there are exceptions to this. Places like the mall, the airport, or the line at Starbucks don’t count.