I'm surprised at how many posters think there's a right and wrong answer on this. Surely all families are different, all children are different - the one constant is the need for the adults to manage the child's sense of self and belonging. The most damaging thing, I would guess, is when the child is never quite sure where they stand because different adults handle it differently, or the rules seem to change between situations. So it's about consistency, and a shared sense of how things will be handled.
Of course, the child's take on it matters as well. My db has one biological child, and two stepchildren with two different involved fathers. I hope we were always warm and inclusive of them, but they wanted different things from us - the older child liked us all, but never wanted to call me auntie or my mum granny - he already had those blood relationships and he saw this as loyalty to them. The younger embraced us much more closely as her family. Both fine. They are now young adults and I am tremendously fond of them and enjoy their company.
I guess part of why it worked was because the adults checked expectations with each other, and because it was always understood that though you can't dictate people's feelings, there is pretty much always a way to avoid hurting a child.
In OP's case, either the grandmother just assumed everyone would see the appropriate action as she did - in which case the adults need to do more checking about shared assumptions - or she just forgot. I would expect her to at least discuss it with her husband - they could then have chosen to discuss with parents, or just to make sure they never got to see it.
What shouldn't have happened is what did happen - that it was a surprise to the child, that the adults didn't know the position of the other adults, and that a mixed message was sent to the child: "You are our grandson... oh, not really".