Honestly, you needed to jump in much earlier. You say you weren't hovering, but you clearly heard and saw everything going on.
As soon as the running away started, well before the hiding sweets, I'd have jumped in. Spoken loudly to my child in a very cheery voice, come on XXX we've got to go now, we've got a special treat to look forward to today and we can't be late.
I'd have then made something up, a trip to the library, building a blanket fort at home, making popcorn, anything. Then later, maybe before reading a bedtime story, thrown in a little chat about how to react when people don't treat us kindly. These lessons aren't easy, as of course kids want to feel included, but when you can see it's not happening, divert her attention somewhere else. Each time something similar happens, have another little chat about why some people are unkind and how to handle it. It's also okay for not everyone to play together all the time. It doesn't mean it hurts less, but they come to understand slowly that this is also true. You remind them in a little chat about a time they just wanted to play with one friend.
At 6, some of this, including a kid talking about poopy heads, is normal silly stuff and best ignored. But you can still divert attention at the time and have a chat later about why one child was being particularly silly.
Kids also change quickly at these ages. Kid C could end up your child's best friend in high school, you really can't predict these things, so divert attention for now, but don't demonise the other child either. Not saying you did, but even the silliest kid can turn out well.
Edited to add...the little wretch who made one of my kids cry when they were 4, turned out to be a really lovely young woman when she turned up as a guest at another of my children's weddings. She knows I haven't forgotten it though, just to keep her on her toes (we have since joked about this).