Some people don’t handle their inner world very well. It spills out in the most inappropriate places at the most inappropriate times.
If you aren’t careful you can get caught up in their drama. You can try to help them sort through their struggles or try to make them feel better.
The problem with doing this is that by engaging, not only are you are unconsciously giving them permission to do it again, but you are taking responsibility for their bad behaviour.
The alternative is to put up a boundary around the behaviour.
“I’m sorry you’re having a rough time right now, but you are not allowed to behave like that” is the healthy mindset.
We are all adults here, behaving badly because you are having a bad day is not acceptable.