It would work when imported or after reload, but wouldn't right after receiving it from a trade. After a long time investigating, it turns out the function writing the condition function wasn't reading the condition structure in the correct order, causing it to read garbage and throw an error.
Using ipairs instead of pairs guarantees the structure will be read in the correct order even right after the trade.
The issue was first brought because of this item: https://pastebin.com/UtSHcpXg
It would work when imported or after reload, but wouldn't right after receiving it from a trade. After a long time investigating, it turns out the function writing the condition function wasn't reading the condition structure in the correct order, causing it to read garbage and throw an error. Using ipairs instead of pairs guarantees the structure will be read in the correct order even right after the trade.