The ! makes "success" to become "failure" and vice versa from shell points of view. In shell you can also use && (logical and operation), || (logical or operation) and group expressions using curly braces { ... }. For example:
{ grep root /etc/passwd && ! grep user /etc/passwd; } && echo ok || echo not ok
Remember to put ; before }. See man sh for more details.
Note that above is a plain shell expression with if-else-like logic. If you want to use test command or [ or [[ then you can also use other type of grouping, boolean arithmetics and other functions. See man test.