How to stack inventory items when the las slot of your inventory

I’ve been learning unreal for a few months, I started working on my first game in Unreal. I wanted to start simple so it is a pet game, that’s entirely ui basically. I’m trying to put in an inventory system, I’ve gotten a lot of things working but just a couple of problems.

I got stacking to work but I want my inventory to have a limit of 4 slots so i added a inventory array check, but once it reaches the end the item won’t stack any more. I also want to make it so when an item’s max stack is reached, that’s it, no more of that certain item can be added, in current slot or next slot, but i’m just not sure how to go about it. I used the for loop in the inventory widget to make the slots. Here are some pictures.

Problem (images are placeholders)

Max Slot Check

Find Empty Slot

Add Item