Our Itemid function typically grabs the first matching and available Joomla menu item to construct SEF URLs when outside of the plugin since it can't rely on the current Itemid to determine the path. GJ also isn't using strict SEF pathing since groups can be accessed from so many different locations it can't really be strict. The best way to avoid this is have an All Groups menu item created first and accessible to everyone so it can fallback to that menu item for SEF. You shouldn't have any access issues though as it should only be using Itemids for menus that are accessible.
Have added a feature ticket to see if I can improve this in GJs routing code in a future release, but it's risky as I risk breaking existing links. Right now it just sounds like it's confused on which menu item it should be using. It probably should be doing the following.
1. Does the group have a menu item directly? Yes, then use it. No, then continue.
2. Does the group have a category? Yes, then check if a Category menu item exists and use it. No, then continue.
3. Does the group belong to me? Yes, then check if My Groups menu item exists and use it. No, then continue.
4. Does an all groups menu item exist? Yes, then use it. No, then fallback to profile Itemid.
forge.joomlapolis.com/issues/7909
We will probably have to improve our Itemid function in CB to better support this since it doesn't support extra fallback cases.