Ensure a member's roles for a team are also deleted when the team is deleted

Description

From the last comment on this GitHub issue (and requested to be made into a Jira ticket by GG in peer-to-peer help channel)

Summary
Deleted Team Relationship Prevents Login

It looks like when a Team is deleted using the API https://your-mattermost-url.com/api/v4/teams/{team_id}, the data pertaining to getting team members for a user still remains, as it can be verified by running the https://your-mattermost-url.com/api/v4/users/me/teams/members.

Meaning that as the reducer for state.entities.teams adds team members, data from deleted teams also gets included in that bunch.

I went ahead and added the following condition to this part of the mattermost-redux project to prevent getMyTeamRoles from trying to split an undefined variable, and now everything seems to be put back in order:

However I feel like the real fix to this would be to ensure a member's roles for a team also gets deleted when a team is deleted.

QA Test Steps

1) Login to the webapp on Chrome.
2) Create two new teams (so you have at least 3 team, but it's fine if there are more).
3) Delete one of the new teams.
4) Toggle between the existing teams.

Verify there are no Javascript errors and that the page loads normally (i.e. the page isn't blank).

Mana

None

Assignee

Martin Kraft

QA Assignee

Linda Mitchell

Reporter

Lindy Isherwood

Epic Link

None

Fix versions

Mattermost Team

Platform

Sprint

None

Labels

QA Testing Areas

None

GitHub Issue

None

Components

None

Severity

None
Configure