Logout Update UI Thread Issue

What is the best practice to handle logout with a UI update in an async/await context?

We have a user login function

@MainActor
func login() async throws -> User {
    let creds = Credentials.emailPassword(email: Constants.EMAIL, password: Constants.PASSWORD)
    let user = try await gTodoApp.login(credentials: creds)  //gTodoApp is our App with Id
    print("successfully logged in user: \(user)")
    return user
}

and is called like this

func handleLogin() {
    Task {
        if gTodoApp.currentUser == nil {
            let _ = try await self.login()
            self.toggleAuthStatus() //sets a string on a NSTextField
        }
}

Which works. When logging out we want to update that UI element upon success

func handleLogout() {
    gTodoApp.currentUser?.logOut { error in
        if let err = error {
            print(err.localizedDescription)
            return
        }
        
        print("logout success")
        self.toggleAuthStatus() //sets the string value on a textField
    }
}

However, when the logOut code runs, it crashes when the toggleAuthStatus function is called with a

-[NSTextField setStringValue:] must be used from main thread only

So we wrap the self.toggleAuthStatus in a Task and force @MainActor but this feels really clunky

Task { @MainActor in
    self.toggleAuthStatus()
}

Is that how to handle logging out?

To clarify:

It’s not clear (to me) why self.toggleAuthStatus is on a background thread in the first place. Is the entire completion handler automatically on a background thread - both UI calls as well as networking?

If so, is this a better option when UI elements need to be updated along with the background networking code?

@MainActor
func logout() {
    Task {
        do {
            try await gTodoApp.currentUser?.logOut()
            print("user successfully logged out")
            self.toggleAuthStatus()
        } catch (let err) {
            print(err.localizedDescription)
        }
    }
}

Is try await the “better” option?