Hat drops are very rare. The exact probability is unknown, but it is very small. To find it out, you would need to log your hours of playing over a very long period of time, and not to log the time over 10 hours per week (as it is not counted for the drop system). There is some data, but I don't know if you can actually trust it.
Robot Unicorn says here:
I have 13 idling accounts, and ill talk about what I get in one week counting all of them.
I always find something special like objector or name tag.
More likely I find 1 or 2 hats per week, some of my last drops were Fast learner and Bootie time.
My most lucky week was 4 hats + mann co. orange. Sometimes I find 2 hats in same week same account
Another guy says:
I've got 2 in an old account it had nearly 1000 hrs
All about luck bbg
And one more guy:
2780 hours and I have had many. Around 7
So, again, just don't bother and play. Most hats are not worth much anyway. If you really, really want a particular hat, buy a Key, sell it for metal, and trade metal for the hat you need.