Well damnit.
The Slot-parent is always the container so you don’t have multiple slots with the same SlotIndex and so with that fix
now you cannot directly check what inventory the clicked slot is in.
You could use this to detect if a slot is in the “first” inventory:
int upperSize = event.getTargetInventory().iterator().next().capacity();
for (SlotTransaction transaction : event.getTransactions())
{
Integer affectedSlot = transaction.getSlot().getProperty(SlotIndex.class, "slotindex").map(SlotIndex::getValue).orElse(-1);
boolean upperInventory = affectedSlot != -1 && affectedSlot < upperSize;
// do stuff
}