i think the if (sizeof($user_guid) && $group && ($group instanceof ElggGroup) && $group->canEdit()) would be a better place, what do you think?