The way I approach these situations is by reminding myself that the speaker is implicitly making a request - a request for empathy or understanding. While it's tempting to try to solve their problems, what they really want is for their feelings to be heard.
"Oh, that must have been frustrating."