Elasticsearch and Database indexing providing different results

Description

When a guest user exists, but is not currently on any team, with elastic search enabled those users are not returned when adding users to the team. However, if elasticsearch is not enabled, those users are returned correctly.

I traced this issue to user_layer.go. There is an issue with the way channels are selected when the `teamId = ''`. This is a recent file added to the project.

Recreation Steps -
1. Create a guest user that is not on any team. This can be accomplished by creating an LDAP Guest Filter and logging in as a user matching that filter. (Ie. “board.one")
"GuestFilter": "(cn=board*)"
2. The user will receive a warning that they belong to no teams (expected).
3. The user will be created as a guest.
4. Login as an administrator.
5. Attempt to invite the user to the team.
Invite People -> Invite Guests -> type “bo” in drop down.
6. With ElasticSearch indexing turned on, user “board.one” isn’t available.


7. Turn ElasticSearch indexing off.
System Console -> ElasticSearch -> Enable Elasticsearch Indexing -> false
8. Attempt to invite the user to the team.
Invite People -> Invite Guests -> type “bo” in drop down.
9. With ElasticSearch indexing turned off, user “board.one” is available.

QA Test Steps

See description
The user with no teams should be returned as expected with ElasticSearch indexing on

Mana

None

Assignee

Jesús Espino

QA Assignee

Ogi Marusic

Reporter

Scott Bishel

Epic Link

None

Fix versions

Mattermost Team

Platform

Labels

None

QA Testing Areas

Other (write in QA test steps)

GitHub Issue

None

Components

None

Severity

None
Configure