Take a look at this file:
~Line 110 there are 2 add_action calls to create a join-group button – ‘bp_group_join_button’.
You need to write a function that checks if the user is a member of any group.
If they are, do 2 remove_action calls so that the button is not created.
Except, of course, for the group that they belong to, otherwise the ‘Leave Group’ button will not appear.