This is for T330816: [Epic] Temporary users should not be assigned to user groups. See also T330816#8958447.
We should do this once groups have been disabled for temporary users (see other subtasks of T330816: [Epic] Temporary users should not be assigned to user groups), and also after work to prevent groups being set on temporary users via ApiUserRights (which may involve updating UserDef::PARAM_ALLOWED_USER_TYPES to distinguish temporary users separately).