Hi, hi @AlfieBrooks 
I went ahead and reproduced this by:
- Having an Org user request to join my Team
- Inviting a user not in the Org to join my Team (users in an Org simply get added to a Team, and there is no invitation/pending status)
Between each step, I tried each endpoint:
- Get team membership for a user
- List pending team invites
What I found, is that when the user requested access to the Team…
/orgs/{org}/teams/{team_slug}/memberships/{username}
returns a 404:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/reference/teams#get-team-membership-for-a-user"
}
…and /orgs/{org}/teams/{team_slug}/invitations
endpoint returns:
…an empty array:
➜ ~ curl -L -X GET 'https://api.github.com/orgs/{org}/teams/{team_name}/invitations' \
-H 'Authorization: bearer KEY' \
-H 'Accept: application/vnd.github.v3+json'
[
]
When the invitation was sent to a user not already within the Org to join the Team…
/orgs/{org}/teams/{team_slug}/memberships/{username}
returns:
{
"state": "pending",
"role": "member",
"url": "https://api.github.com/organizations/{org_id}/team/{team_id}/memberships/{username}"
}
/orgs/{org}/teams/{team_slug}/invitations
returns:
[
{
"id": {id},
"node_id": "{node_ID}",
"login": "username",
"email": null,
"role": "direct_member",
"created_at": "2020-09-28T12:04:22.000-07:00",
"inviter": {
"login": "nethgato",
"id": {id},
"node_id": "{node_id}",
"avatar_url": "{avatar_url}",
"gravatar_id": "",
"url": "https://api.github.com/users/nethgato",
"html_url": "https://github.com/nethgato",
"followers_url": "https://api.github.com/users/nethgato/followers",
"following_url": "https://api.github.com/users/nethgato/following{/other_user}",
"gists_url": "https://api.github.com/users/nethgato/gists{/gist_id}",
"starred_url": "https://api.github.com/users/nethgato/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/nethgato/subscriptions",
"organizations_url": "https://api.github.com/users/nethgato/orgs",
"repos_url": "https://api.github.com/users/nethgato/repos",
"events_url": "https://api.github.com/users/nethgato/events{/privacy}",
"received_events_url": "https://api.github.com/users/nethgato/received_events",
"type": "User",
"site_admin": true
},
"team_count": 1,
"invitation_teams_url": "https://api.github.com/organizations/{org_id}/invitations/{invite_id}/teams"
}
]
So to your question:
Does the pending state only apply for invites? and doesn’t work when requesting to join?
That really does seem to be what’s happening, but it’s not clear that this is expected behavior. Now that I’ve documented these steps here, I’m going to followup with our team to find out if we’re bumping up against unexpected behavior, or perhaps there was something done incorrectly in my reproduction steps.
Thank you for your patience in the meantime! 