The Russian translations of “a hat” are – шапка, шляпа. But for Russians “шляпа” means only a special hat with a crown and a wide brim, something like a cowboy hat. Of course, they use this thing to protect their heads. But except of that they use this word in different idioms.
1. Дело в шляпе. (A business is in the hat.) It means that something is completed successfully. An English analogues: it is in the bag/it is over/it is covered. 2. Все накрылось шляпой/все накрылось медным тазом (Everything was covered by the hat/ by the copper bowl.)It means that everything is crashed, ruined. Everything is dead in the water. 3. Снимаю шляпу. It is like English – My hat is off to you. 4. Then, there is a verb – прошляпить/ to miss, let slip the chance. Он прошляпил такой замечательный шанс. (So great chance slipped through his fingers.) 4. But who could “прошляпить”? Of course, шляпа/ passive person, looser. Он настоящая шляпя. Прошляпил такой хороший шанс. Эх ты, шляпа! 5. Шляпа can mean something useless, having bad qualities. Этот фильм - просто шляпа. Этот учебник совершенно бесполезен – полная шляпа.
There exists an opinion that that “bad” шляпа originates not from German slape (шляпа - a hat), but from schlappe - misfortune, failure.
As to a native, it seems, you make learning Russian only worse. These subtleties have no use until at least C1 level. "Дело в шляпе" = " It's in the bag " is an idiom for B2.