There are two problems that I uncovered after the investigation.
First, the automatic group names are updated whenever the default locale of the forum is changed. However, the default automatic group names for each locale may be similar to the name of an existing group which is the cause of the Name has been taken
error. The fix for this is pretty straight forward, if the localized name has already been taken, we simply fallback to the default name for that automatic group.
https://github.com/discourse/discourse/pull/4662/commits/59dfb51a35ce37c91d34e9c1817c6e536735f1bb
Next, a group name change means all the existing group mentions becomes outdated and we don’t have a warning discouraging users from changing group names like how we do for username change.
Instead of implementing the warning, I went ahead and implemented the feature to remap group mentions in all posts whenever a group name is changed.
https://github.com/discourse/discourse/pull/4662/commits/706b4f6b9faf1f820a294e83f82b0b5a5dba0475