The stacking logic of the rack doesn't take objects inside the entering items into account. Is it actually necessary that the pallet and boxes are separate object or should they just look like they are?
If not, you could instead create a custom flow item that looks like a pallet with stacked boxes but is in fact just a single object. If you adjust the size of the bounding box ("More Properties" -> General Tab -> "Edit Shape Factors"), they will be stacked correctly.
FullPallet_as_FlowItem-fm.fsm
Otherwise, you can add logic to the "On Slot Entry" trigger of the rack that adjusts the position depending on the height of the stacked items on the previous pallet. You will still have to limit the number of pallets per slot through a condition in the Slot Assignment Strategy though.

create_pallet_with_box_1.fsm
Note: If you are replying to an answer or a comment, please use the comment function instead of creating a new answer. You can change your answer into a comment through the options accessed by the gear symbol. 