I just spent time reading through the code.
I can explain how it works now
-
If you change the default title on a group then all the users with the old title get a new title (Good ™)
-
If you add a title to a group then all users with blank titles will get the title (Good ™)
-
If a user is removed from a group that grants title, title is revoked if it matches (Good ™)
-
If a user is added to a group and has no title, we will grant a title (Good ™)
What we have that is inconsistent and confusing is:
-
If a user is added to a group that has primary group set we will unconditionally set primary group, regardless of what it was previously. This deviates from the “title” behavior.
-
If a group is saved and you “flick” primary group on, off, on. Primary group will be set unconditionally for ALL users regardless of what it was before.
-
If you remove membership from one group and 2 groups grant a title, we will blank out your title, but NOT set it to the other title.
Due to this inconsistency and confusion, for your use case you have to:
-
Ensure user is only in one group that has “primary group” set
-
Edit that group, set title to gibberish, save, then change it back… save.
Clearly this is all a bit crazy.
So what we should do here is:
-
If we strip title, we should check if there is a new title we can grant you.
-
We should always prefer title to match you current primary group if it grants a title. (So if we have 5 titles to pick from and your title is set to one of the 5 we should pick the right title and not override a custom one)
Those 2 fixes will HEAVILY reduce all the confusion around this. The underlying problem is that there is a relationship between auto title for group and primary group that is not properly captured in code.
Also UI wise it is “Default title” is on one screen, “Automatically set as primary group” is on another screen, this is far from ideal cause these two features are related, also the copy should explain how they are related. (Clicking on the title will take you to primary group if primary group is set)