I firmly believe that doing one's best in school is important. And it's different for nearly every kid.
For example, my ds was capable of doing extremely well, had no difficulties with learning or behavior or medical issues, and we expected excellent grades. He achieved that, and graduated from a very tough technical college with a 3.5 GPA.
My dd has multiple medical issues, plus anxiety and depression. She is considered disabled and receives SSI. It took her 7 years to get through high school in an online program with a 504 plan, and her GPA was 1.0. Yet for her, that was triumphant. She did her very best under difficult circumstances, multiple hospitalizations, and pain and illnesses.
In your daughter's case, I would not connect having a phone with doing "well" in school, if it means grades. You can still expect good behavior at school, being prompt, turning in homework on time (whether it's A+ work or if it's C-, if that's her best in that subject), not skipping any classes, being able to ask for help if it's needed, etc. In other words, not grades, but performance.
And the other criteria is personal responsibility. A kid who wants a phone, who loses backpacks and jackets, who routinely breaks things, who lends things like electronics to random kids at school, who can't put her bike away, who's late coming home from a friend's house, doesn't get a phone. But a reliable, careful, responsible child might. A child who will agree to certain sensible rules, such as parental access to passwords, parental rights to check the phone at any time, no phone use during school hours except for a true emergency, and turning in the phone to a charging station outside the bedroom at an agreed-upon hour, might earn a phone.
I'd evaluate what standards you're establishing as far as school performance, and disconnect those from phone ownership. But I'd still keep the end of the year goal, under different criteria (behavior, trustworthiness, reliability, etc).
And I'd make sure she was getting help at school, through a 504 plan or IEP. She's under too much pressure, without enough support, it seems. She might really profit from having a 504 plan (which offers accommodations, not a differently structured curriculum). A 504 plan might allow her more test-taking time, fewer tests at a time, etc.
I think she learned a valuable lesson from this experience, and I sincerely hope that you have noticed how much stress she's under, and why a phone shouldn't be a reward for grades that may be unattainable.