This looks like a SwiftUI bug rather than an issue with your transition.
HStack {} is not a no-op inside a ViewModifier. Since body uses @ViewBuilder, adding it changes the generated view hierarchy. Without it, the modifier returns a single modified view; with it, SwiftUI creates a different container type (TupleView internally).
Even though both versions render the same, SwiftUI’s diffing and transition system is sensitive to view structure. In this case, the different hierarchy appears to change an internal optimization path.
The clue is the behavior:
That suggests SwiftUI removes the live view too early while still animating its transition snapshot. Adding the empty HStack changes the view tree enough to avoid this behavior.
So the HStack isn’t actually fixing the animation. It’s changing the view hierarchy enough to work around what appears to be a SwiftUI implementation bug.
I’d recommend filing a Feedback with Apple and including this minimal reproducible example.
