HubSpot and OneTrust in React

Hello everyone!
I have an issue regarding cookies.
We do not have a HubSpot hosted site, and are instead loading the tracking code in our React application.
We use OneTrust for cookie consent, and am having troubles making it work properly. When not giving consent, it is still tracking the user so it seems like it is not working the same way as with a lot of other cookies where when consent is not given, it changes the script so it doesnt load.
I have tried adding this

if(OnetrustActiveGroups.includes("C0004")){
 _hsq.push(['doNotTrack', {track: true}]); //enable tracking for user
 }else{
 _hsq.push(['doNotTrack']); //turn off tracking for the user
}

into my optanonWrapper, like it says here on OneTrust website:
https://my.onetrust.com/s/article/UUID-25510bd6-6447-4594-2b90-2f875b310773?language=en_US
But then the first time a user comes to the page, that page will never be tracked as when they first arrive, consent has not been given.
Has anyone else faced this issue or have some suggested solutions for me?
Thank you!

Hi, @NATJ :waving_hand: Thanks for your question. Welcome to our community. I’d like to invite some of our community experts to the conversation — hey @TomM2 @miljkovicmisa @Teun, do you have any troubleshooting tips you can share with @NATJ?

Thank you very much for taking a look! — Jaycee