Why isn't the UI removed from the player when the HandleBlackUI function is subscribed to a second time?

The following code is supposed to assign the agent to an optional agent then eventually send them to a function that adds a black UI to their screen if they don’t have it already displayed, or remove the black UI from their screen if they have it already displayed. But the problem I’m running into is that the black UI is being added but isn’t being removed when it is supposed to be removed. I’m not sure why the UI isn’t being removed, any idea?