Open popup on URL page load - Can't get this to pop

I’m struggling to open a popup on a page load with URL.

I’ve got a dynamic CPT template ‘restaurants’ and I’m using JetFormBuilder to submit restaurants from the front-end. On post submit, the user is redirected to the submitted restaurant page. Also, with JetFormBuilder, I am adding a #to-do-next parameter to every new submitted post.

The post submitted URL then looks like this:
https://domain.com/?post_type=restaurants&p=217/#to-do-next

I’ve got a Bricks popup created with conditions setup to show on ‘Entire Website’.

What I’m hoping to achieve is that once the form is submitted, and the user is redirected to the restaurant page, I want to trigger this popup based on the condition that the URL contains ‘#to-do-next’.

This is my javascript:

document.addEventListener('DOMContentLoaded', function() {
    // Check if the URL contains the fragment identifier '#to-do-next'
    if (window.location.hash === '#to-do-next') {
        // Trigger the Bricks popup with ID 208
        bricksOpenPopup(208);
        console.log('Popup with ID 208 triggered because of #to-do-next in URL.');
    }
});

The popup doesn’t open, but I get the console log saying it has triggered.

I’ve tested opening the popup other ways like button, and the popup works fine, it’s just not opening with the URL.

Any ideas what am I missing here? The ID (208 in my case) should be the ID of the popup template, is that right?