Ok, I left ChatGTP and used Google to do the research myself and it led me to the official documentation https://developers.google.com/gmail/api/reference/rest/v1/users.messages/batchDelete which says that it's not the <a href="https://www.googleapis.com/auth/gmail.modify">https://www.googleapis.com/auth/gmail.modify</a>
scope I need but instead <a href="https://mail.google.com/">https://mail.google.com/</a>
and with that change the code works.
I tried to tell this to ChatGTP, but when I do it just throws an error: "An error occurred. If this issue persists please contact us through our help center at help.openai.com."