I'm trying and failing to dismiss a view using the dismiss environment

I have a SwiftUI view that I'm trying to dismiss with a button.

Here's the dismiss code:

struct MyBackButton: View {
    var backButton: Bool
    var dismiss: DismissAction
    var body: some View {
        Button(
            action: dismiss.callAsFunction
        ) {
            HStack {
                if backButton {
                    Image(systemName: "chevron.left") 
                        .imageScale(.large)
                    Text("Write!")
                } else {
                    Text(" ")
                }
            }.foregroundColor(Color("AccentColor"))
        }
    }
}

The containing view contains the environment declaration and the button code:

struct ProjectView: View {
    @Environment(\.dismiss) private var dismiss
here's the body of the view containing the following modifier that creates the button
.configureView("Write!", publisher: publisher, dismiss: dismiss)`

When the button is pressed the dismiss action is invoked but nothing happens.

I've tried many variants of this code without success. Any help welcomed.

I am using Xcode 15.3 beta.

I'm trying and failing to dismiss a view using the dismiss environment
 
 
Q