The simplest way to avoid using an extra container like HStack is to annotate your body property as @ViewBuilder, like this:
@ViewBuilder
var body: some View {
if user.isLoggedIn {
MainView()
} else {
LoginView()
}
}