UIPrompt appears and then disappears suddenly?

Basically what the title says. I’m trying to create a wrapper for the UiPrompt functionality, and I got it to appear like needed, however, it only appears for less than a second for it to disappear again. Why is this? I’ve tried implementing a hidePrompt() function, and even added a Citizen.SetTimeout() to try to get it to remain on screen. Is there any way I can fix this?

handler.lua (shared_script)

PromptManager = {}
PromptManager.Functions = {}

PromptManager.Prompts = {}

function PromptManager.Functions.createGroup(groupText)
    return {
        id = GetRandomIntInRange(0, 0xffffff),
        name = CreateVarString(10, 'LITERAL_STRING', groupText),
    }
end

function PromptManager.Functions.createPrompt(attributes)
    local str = CreateVarString(10, "LITERAL_STRING", attributes.text)
    local prompt = PromptRegisterBegin()

    PromptSetControlAction(prompt, attributes.control)
    PromptSetText(prompt, str)

    if (not attributes.mode or attributes.mode == "standard") then PromptSetStandardMode(prompt, 1) end -- Standard Mode

    PromptRegisterEnd(prompt)

    local result = {
        id = prompt
    }

    -- Merge the attributes into the result table
    for key, value in pairs(attributes) do
        result[key] = value
    end

    return result
end

function PromptManager.Functions.showPrompt(prompt, group)
    PromptSetVisible(prompt.id, true)
    PromptSetEnabled(prompt.id, true)
    if group then PromptSetGroup(prompt.id, group.id, null) end
    table.insert(PromptManager.Prompts, prompt)

    if group then PromptSetActiveGroupThisFrame(group.id, group.name, null, null, null, null) end
    
    for _, prompt in ipairs(PromptManager.Prompts) do
        local id = prompt.id
        local mode = prompt.mode or "standard"
        local onSuccess = prompt.onSuccess
        local onFail = prompt.onFail

        if mode == "standard" and PromptHasStandardModeCompleted(id) then
            if onSuccess then onSuccess() end
        end

    end

end

function PromptManager.Functions.hidePrompt(prompt)
    PromptSetVisible(prompt.id, false)
    PromptSetEnabled(prompt.id, false)
    
    local indexToRemove = -1
    for i, p in ipairs(PromptManager.Prompts) do
        if p == prompt then
            indexToRemove = i
            break
        end
    end
    
    -- Remove prompt
    if indexToRemove ~= -1 then
        table.remove(PromptManager.Prompts, indexToRemove)
    end
end

and then I have the test.lua that registers a command and calls everything (client_script):

RegisterCommand("setPrompts", function()
    local promptGroup = PromptManager.Functions.createGroup("test")

    local testPrompt = PromptManager.Functions.createPrompt({
        text = "Test prompt",
        control = 0x760A9C6F, -- G key
        onSuccess = function() print('Pressed test') end,
        onFail = function() print('Test has failed') end,
    })

    PromptManager.Functions.showPrompt(testPrompt, promptGroup)

    Citizen.SetTimeout(8000, function()
        PromptManager.Functions.hidePrompt(testPrompt)
    end)


end)

Thanks in advance!