code: func (api OrganizationsAPI) autoAcceptSubOrgInvite(invite *invitations.JoinOrganizationInvitation, mgr *organization.Manager) (bool, error) {
  	globalid := invite.Organization
  
  	// If this is an invite for a root organization we obviously aren't a member of a parent yet
  	if !strings.Contains(globalid, ".") {
  		return false, nil
  	}
  
  	// Check for username so we only auto accept already registered users
  	// Not sure if this is needed but it doesn't hurt to check
  	username := invite.User
  	if username == "" {
  		log.Debug("can't auto accept the invite because the username is not known")
  		return false, nil
  	}
  
  	// Check if we happen to be a member or owner of a parent org
  	orgs, err := mgr.AllByUser(username)
  	if err != nil {
  		return false, err
  	}
  	inParent := false
  	for _, org := range orgs {
  		// adding the  "." is required here.
  		if strings.HasPrefix(globalid, org.Globalid+".") {
  			inParent = true
  			break
  		}
  	}
  
  	if !inParent {
  		return false, nil
  	}
  
  	// add the user
  	org, err := mgr.GetByName(invite.Organization)
  	if err != nil {
  		return false, err
  	}
  	if invitations.RoleOwner == invite.Role {
  		// Accepted Owner role
  		if err := mgr.SaveOwner(org, username); err != nil {
  			return false, err
  		}
  	} else {
  		// Accepted member role
  		if err := mgr.SaveMember(org, username); err != nil {
  			return false, err
  		}
  	}
  	// set the invite to status accpeted
  	invite.Status = invitations.RequestAccepted
  	log.Debug("Invitation auto accepted because the user is already an owner or member of a parent organization")
  	return true, nil
  }
docs: // autoAcceptSubOrgInvite tries to auto accept an invitation if a user is already a member or owner in a parent organization