Change the condition to `(and error-messages flycheck-display-error-messages-function)`.  This conveniently allows a user to suppress the display of error messages by simply setting the variable to `nil`.