Mediation is not only for when things are terrible... you could request to meet with the grandparents with a mediator. Purely the official nature of it may convince your daughter's grandparents of the serious nature of how you feel. It could also be helpful to have a neutral person present when the 3 of you talk.
Better to set boundaries now when it's something as minor as hair (but the issue is a big one; disregarding reasonable requests by the primary custodial parent, that are not transient in nature... aka not something that "stays at gramma's house"), before it starts turning into bigger issues later on... like withdrawing her from a chosen preschool/elementary school, putting her on (or taking her off of) medication, etc.
As to the "talking back", and having to repeat yourself over and over and over and OVER... a big part of that is the age thing. You'd be dealing with it regardless of where she spends her time. That she spends time away where undesirable behaviors are reinforced muddies the issue (and makes it harder), but you'd have the issue no matter what. Especially if that's her preferred way of either asserting her independence, or if that's just the way her mind is working right now. My very verbal son was incapable of not arguing over every little thing he didn't like OR didn't understand. I couldn't tell him no arguing (that was the way he was figuring out his world), but I COULD set very clear boundaries as to HOW he was allowed talk. IE: No whining, yelling, name calling, throwing fits. He'd get a "warning" (aka notice he was doing it, at that age many children just aren't aware), to give him the opportunity to change the behavior... and if he didn't consistent results. ((You NEVER get what you want when you whine (or throw a fit)... whining didn't = timeout, but yelling, namecalling, throwing fits and in other ways being mean/trying to hurt another person = timeout.))
My own mum watched my son for me while I was in school for years. No matter how appreciative (and how voluntary) that process was, there was also readjustment time, and sometimes it was hard hard hard. (ditto when daddy had him, and dad was living with us!!! 3 was the hardest period (we had the terrible threes in our house).
Eventually he "got" that the rules with ME were 100% consistent. My mum allows whining, and my husband caved each and every time (be he only saw our son at most, one day a week). I can't count the number of times I'd get the whole whining "Naaaanaaaa lets meeee do ________. Sheeeeeee's not meeeeeaaaan."
I found the best way to deal with it was to simply be matter of fact, and not waste emotional energy/confuse the issue by being upset.
"Different rules, kiddo." and then the reminder "You're whining, btw, love. What's the rule about whining?"
"I don't get what I want."
<grinning at him> "So... even if I WAS going to let you do it, and you were WHINING, it wouldn't happen, huh? I'm NOT going to let you do _______, but whining guarantees it. "
This might kick off a fit, which would then = timeout, and then we'd have to "talk about it" figuring out what was going on when, and a better way to do it next time. It might NOT kick off a fit. Regardless though, DS learned that Mum is a rock. And eventually learned to work within different rule sets. Kids are good at that. Very few of them use the same rules at school and at home, for example. But it does take them a little while to figure out "what belongs where" in any situation.