
Technically, she didn't actually speak. Nope, but the First Amendment protects your freedom of expression, even rude expression. There are limits on obscene speech, but while coarse, rude, and - your mother would tell you - low class, the middle finger isn't usually meant as a sexual gesture. So it's not obscene by legal standards.
So, as the court told the officer, you can't penalize a person for her rude, ungrateful perfectly legal expression.