Putting the following code before the call to StaticPopup_Hide should prevent the Popup from declining the invite:
Code:
for i=1, STATICPOPUP_NUMDIALOGS do
local dlg = _G["StaticPopup"..i]
if dlg.which == "PARTY_INVITE" then
dlg.inviteAccepted = 1
break
end
end
It loops through all StaticPopups and sets the
inviteAccepted flag for the one that is showing the invite message.