Try CallSecureProtected as wrapper around UseItem.
Lua Code:
if IsProtectedFunction("UseItem") then
CallSecureProtected("UseItem", bagId, slotIndex)
else
UseItem(bagId, slotIndex)
end
If this does not work I'm not sure if there is a way to make your code NOT taint the inventory code. I'm pretty unsure why the code get's insecure though. Are you hooking/chaning any inventory code for your menu? If so try SecurePostHook instead of ZO_PostHook etc.