So I'm at work, hanging with the girl I'm interested in at her desk. We've been chatting and joking for a while, then I leave to get a drink.
When I come back, another guy that I work with(but do not know--he's fairly new) is there and she's having a pretty invested conversation with him(she's asking him about where he's from and joking with him about it, etc.). I immediately feel threatened, but decide to just hang back and wait rather than trying to override their conversation. He isn't really investing in the convo much other than just giving her simple answers and acting pretty laid back as well(he had originally come over for a work-related issue), and he senses that I'm ready for him to leave, so he does.
After he does, she turns back to me with a nearly totally uninterested/displeased frame that was pretty much opposite of what she was just giving that guy. Now I feel like yeah, I blew it. I couldn't recover from it, so the remaining time I had with her was pretty much ruined.
I should have overcome my initial reaction and decision to hang back, and stepped in and introduced myself to the guy in a friendly manner and involved myself as an AMOG would have. My excuse was that I was tired and hungry (and too lazy to bother). It was a tough lesson, and a shit test from her that I failed.
Treat me accordingly, please. I need this one burned into my memory so I never do it again.

Also, what could I have done to recover from this so the rest of our time wasn't ruined?