Can't see users in groups?

I’ve written a custom authentication plugin to integrate with one of our systems. As part of the login process, I assign users to a specific group. I’m having issues with this, as after the group is created I don’t see the user as part of it in Users/Groups -> Groups -> [GroupName], but on the User/Groups -> Users -> [UserName] page, I do see the user as part of it.

If I restart the server or clear the group cache, this issue partially goes away. The group counts are accurate, and I can see the users listed. However, these users still don’t show up on other people’s contact lists (I have the groups configured via contact list sharing) until the server is restarted.

This is the code I’m using to add them to the group. Any suggestions as to how I can improve this to not require the server to be restarted every time I add a user?

String domain = JiveGlobals.getProperty("xmpp.domain");
        JID uid = new JID(username+"@"+domain);         Group g;
        try {
            g = groupManager.getGroup(group);
        }
        catch (GroupNotFoundException gnfe)
        {
            try {
                g = groupManager.createGroup(group);
            }
            catch (GroupAlreadyExistsException gaee)
            {             }
        }         GroupProvider provider = groupManager.getProvider();         boolean groupfound = false;
        for (String cur : provider.getGroupNames(uid))
        {
            if (cur.equals(group))
            {
                groupfound = true;
            }
        }         if (!groupfound)
        {
            provider.addMember(group,uid,false);
        }