Seems that this was a fundamental design problem that was resolved
with 3b6ee8cee7.
Since the vertex group names are stored on the mesh now, we can
just store their state in the undo mesh, and restore it when decoding
an undo step.
Pull Request: https://projects.blender.org/blender/blender/pulls/137225