You are using the new Observation Framework (iOS 17 / Swift 5.9), and the problem is that @Environment gives you the LoginViewModel object itself, but it is not directly bound.
To use $loginVM.showApiAlert in .alert, you need a two-way binding, but you don't have it because $loginVM does not exist in this context. You can wrap a property in Binding directly in .alert.