I've got a similar situation with DD. She's 4 and at nursery. There's 2 girls who she was always friendly with that will now only play with each other when they're both there, but if one of them is off then the other is straight to DD wanting to play.
I picked her up the other day and she was really quiet, apparently the latest was she couldn't play with them because she 'isn't pretty' - the reason she wasn't pretty? They were wearing imaginary jewellery and she wasn't! So she imagined some jewellery. Still not pretty.
I was so cross. DD plays with all the kids, she's not a social outcast in any sense, but these kids are like this to everyone unless one of the 2 isn't there.
I offloaded to my therapist, because I'm aware I'm a chronic people pleaser, bwry much a 'giver' and I get taken advantage of by 'takers' and it hurts. I don't want DD to be the same way. I told her I wanted to tell DD to not play with them if they're not nice, but was worried she'd get in trouble for excluding them!
Therapist told me not to be daft, that that's perfectly reasonable. So I've told DD next time one of them says they want to play with her she's to say 'no, you were nasty to me and it made me sad, so I don't want to play with you. Good friends aren't nasty.'
Whether she will or not I don't know, but I'm hoping I'm giving her the tools to stand up for herself, and to know it's ok.
I have spoken to nursery, and DD says she tells a grown up if they're nasty, so I think they're dealing with it as it happens but it makes my heart ache that I can't fix it for her 