I think your question leads to a discussion of what type of headband is on the hat you want to use.
For hats with stiff headbands, it works better to put the light above my ear, not in front.
.
My hats with soft flexible headbands, such as my Beret and Irish Flat cap
work more easily than hats with stiff headbands, such as my Panama Hat, Stetson, or some Baseball Caps.
I agree that tucking under the front of a hat with a stiff and close fitting headband, is a bit awqward because the headband is stiff, and tight to the head, so the light wont aim forward, unless I put the hat on further back on my head than normal, and with the light under it, the hat is loose on my head. I dont run around like that, I sit still and look at something in my hand. It is not ideal.
For stiff headband lights, the clip to the brim is much more secure. It does have the potential to damage the hat brim. I would not clip to the brim of my Panama hat.
I just did a test for you, and put a light under the Panama headband, over my ear, it works better than tucked under the headband in front.
.
What kind of hat do you wear?