What's a girl to do?

Hi,
Is this grammatically correct to say “What’s a girl to do?”? Why?
Thanks.

And does it mean “What is the thing a girl has to do?”?

It’s idiomatic.

What’s a girl/boy/man/woman to do = what could I possibly do otherwise?

It’s used like this:

My new handbag is expensive, but then, what’s a girl to do?
(My new handbag is expensive but what else could I possibly do (than pay)?)
It’s use isn’t literal. An answer such as ‘buy a cheaper one?’ is not expected. It’s a humorous way of cheekily justifying something, as if no other option is possible - even if it is!

Best answer ever!
Thank you very much.