It is sad when this happens and painful for the kids. Middle school is a time of change - making new friends, discovering your interests and where you fit in. If your daughter is shy, there are other kids like her in school! Suggest that she seek them out rather than just wishing she could break into this popular crowd with her friend. I would encourage her to approach new kids who are not part of the popular crowd and also to join any after school clubs/sports/activities.
Good luck! I have one who finished middle school in June and one who just started in September.