This is a brief lesson because I could find almost zero additional resources. (I'm not used to that!)
In the prison, when a person (prisoner) is "in the hat" it means he or she is marked for death. This is usually for suspected narc-like behavior.
A commenter on GoodReads.com defines the phrase: " In the Hat refers to a notorious practice in prison where drawing a name out of a "hat" almost means certain death."
But Gangland on the History Channel didn't mention drawing names, just the phrase as "code" for a plan to kill a fellow prisoner. (This isn't Harry Potter!