SwiftUI animations for List

I've got a List along the lines of:

       List {
           if model.selectionType == .module {
                Section(header: Text("Module")) {
                    ModuleView(model: model)
                }
            }
            
            if model.selectionType == .text {
                Section(header: Text("Text")) {
                    ... stuff ...
                }
            }
            
            if model.selectionType == .expression {
                Section(header: Text("Expression")) {
                    ExprView(model: model)
                }
            }

           ... etc ...
     }

And I've noticed that when selectionType changes, the animations are odd. Like the section headers appearing on top of each other. It looks bad.

Now, I was wondering if that's because this isn't really declarative, since there's a bunch of ifs in there, so SwiftUI gets a bit confused about identities, and doesn't do very well with the animations. If instead the view hierarchy stayed the same and things were just hidden, then it might not have this problem.

Then again, I see other code with ifs (such as Apple's SwiftUI tutorial), and there doesn't seem to be another way to conditionally hide a List section (hidden() still shows the section background).

I'm not seeing any animation. Maybe I didn't set it up right

struct ContentView: View {
    @State var test = 0
    var body: some View {
        HStack {
            List {
                testView(value: 0)
                testView(value: 1)
                testView(value: 2)
            }
            Picker("Pick", selection: $test) {
                Text("0").tag(0)
                Text("1").tag(1)
                Text("2").tag(2)
            }
        }
    }
    
    @ViewBuilder
    private func testView(value: Int) -> some View {
        if test == value {
            Section{
                Text("\(value)")
            }
        }
    }
}