I faced a similar issue recently.
First you have to set the z-index of the SquareView to be higher if it is selected. That is not enough though, as it will only be in front of SquareViews in the same GridRow.
That is because the z-index of nested views in SwiftUI does not propagate to parent views. So we must also set the z-index of that GridRow to be higher if it contains the piece being dragged.
Store the piece being dragged's id and use that for the comparison!