Someone is in a hat or under a hat?
I can see your puzzled expression, even if I wasn´t there...It´s because "under" also means some object "covered" by other. https://www.espressoenglish.net/prepositions-of-place-in-english/
But then, if it´s too easy then there might be some kind of "catch", and it was the case.
Because there are day-to-day expressions in English which they put the learn to test, so "in hat/in red/in spetacles" may convey that sense I have dealt with.
One thing is certain, this one you will never unlearn! I had a teacher that said that the mistakes are the mother of all learning!
Be welcome to the world of catches in tests and exams, smell the coffee!