The that in this sentence is a demonstrative pronoun that refers to Trying to get a rabbit out of the hat. Magicians are always pulling rabbits out of hats. He doesn't know anything about the sorting ceremony. Had he understood why the hat was there, he wouldn't have had that wild thought about pulling a rabbit out of the hat. In addition, the punctuation is not formally correct (I don't know whether this is because it's the way JK Rowling wrote it or the way you copied it: I think there ought to be a period after "wildly". If, indeed, the words in bold are Harry's thoughts, as the 12 words before "Harry thought wildly" are, then they ought to be in italics. Still, it wouldn't matter:
Maybe they had to try and get a rabbit out of it, that seemed the sort of thing that happened here.
is a comma-spliced sentence that can't be used in formal writing, only in novels. To be formally correct, and to make the pronoun function as a relative rather than as a demonstrative pronoun in this sentence, that has to be replaced by which.
Since you're speaking in generalities, you can use the first person plural pronoun, even if you regard yourself as one of the exceptions (it's assumed that generalities can have exceptions). For example, I might say:
Us men, we never remember our anniversaries.
even if I happen to be a man who always remembers to make a reservation for our anniversary dinner well ahead of time.
I'm talking about men in general, and if I happen to be a man, that's the best way to say it – I should include myself in the first group, since I'm clearly a member of that group.
I suppose I could say:
Those men, they can never remember their anniversaries.
but that seems more fitting for a women to say, not a man. If a man says it that way, he's muddling the conversation, by creating three groups instead of two.
Since these kind of remarks are often intended to be somewhat humorous, we dampen the humor when we get so particular about the pronouns. It's better to be a little self-deprecating and include ourselves with the group, even if we don't exhibit the behavior.
When your friend says:
Indians are the worst drivers, we can take a turn from anywhere!
that's more likely to make me smile or laugh, whle:
Indians are the worst drivers, they can take a turn from anywhere!
sounds more like a peeve or a rant against others in a group that person belongs to, and some of the humor is lost.
Best Answer
Pronouns take the place of a noun.
So if you see his immediately followed by a noun, it's very likely a determiner, because two nouns in a row without a conjunction doesn't work.
Also if you can replace his with an article, such as a/an or the, and the sentence still makes sense, it's a determiner.