I think extracting a `shouldPrintMessage` method from this would clarify this code.