How to hide/show menu items using based on group membership?
A better way of doing this might be to use Drupal's built user permissions. You can use a 3rd party module such as https://www.drupal.org/project/content_access so set specific access

E.g. so that only certain roles have access to those certain pages. Then drupal will automatically handle the showing/hiding of the menu links if they depending if the user does/doesn't have access to that page