Solved it. It seems like the problem was that I was disabling the UIDocument component as soon as it was spawned in the scene with the intention of hidding the UI. I tried to change to disable the GameObject instead, but it seems like even that would break the UI as well (if someone knows why this happens, or if is a bug do let me know please). It seems like the best way to hide the UI is to change the visibility of the root element of the UI document.