Exclude child categories from a query

There are 2 posts for this already but I can’t glean an answer from them. This is such a simple request but I cannot get it to work.

I have categories with children - e.g. Category = Hats, subcats=black, red, green
I have 4 posts in HATS, and several posts in black, red and green - A post in Black will only have ‘Black’ category selected, not ‘Hats’.
I want to fetch only the posts in HATS - and NOT those in the child categories.
But everything I try returns all posts in Hats AND black, green and red… or returns nothing.