SwiftUI - If inside ForEach loop

filter your data BEFORE passing it to ForEach constuctor.

ForEach(self.documentItems.filter {self.checkSearchString(document: $0)}, id: \.self) { document in
    HStack(spacing: 0)
        {
            ListRow(document: document).tag(document)
        }
}

You need to use Group to wrap different views provided by condition, like below

 ForEach(self.documentItems, id: \.self) { document in
   Group {
     if (self.checkSearchString(document: document))
     {
         HStack(spacing: 0)
         {
             ListRow(document: document).tag(document)
         }
     }
     else 
     {
        EmptyView()
     }
   }
 }