Prevent removal of user groups after validation fails

(cherry picked from commit 1ed027d17107fbc2709f27fd19d92dcd8e3656c1)