[HOLD for payment 2022-03-22][$500] Group Creation - Duplicate user can be seen in search list - @parasharrajat
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
- Select a user from the list. (must be included in the recents list)
- Search for the same user.
- Clear the search.
- Duplicate user is shown in the list.
Expected Result:
There should be only 1 user displayed.
Actual Result:
Duplicate user can be seen in search list
Workaround:
N/A visual issue.
Platform:
Where is this issue occurring?
- Web
- iOS
- Android
- Desktop App
- Mobile Web
Version Number: 1.1.7-3
Reproducible in staging?: yes Reproducible in production?: yes
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

Expensify/Expensify Issue URL:
Issue reported by: @parasharrajat Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1633961442111100
Triggered auto assignment to @robertjchen (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
Correction to the issue: This issue is coming on the new Group Page, not on the search page. This also affects other parts of the app where a select contacts list is used.
Proposal
There are two things that I can think of and I would like to ask what is expected behavior.
- This issue is caused due to we don't filter the
selectionOptionsfrom the contacts list on search. https://github.com/Expensify/App/blob/7fac08ca1cb5d9f1da855f9fd94b4d190b8680be/src/pages/NewGroupPage.js#L223
if we pass the selectionOptions here, it will filter the list correctly but If we search for a user that is already selected, then No result found message will be shown.
- We can filter the sections so that they do not show selected users in
getSections. Here, I filtered theselectionOptionsfrom recent and contacts sections.
const filterstring = _.reduce(this.state.selectedOptions, (str, {login}) => `${str} ${login}`, '');
const filterSelectedfromRecents = _.filter(this.state.recentReports, ({login}) => !filterstring.includes(login));
const filterSelectedfromPersonalDetails = _.filter(this.state.personalDetails, ({login}) => !filterstring.includes(login));
sections.push({
title: this.props.translate('common.recents'),
data: filterSelectedfromRecents,
shouldShow: !_.isEmpty(filterSelectedfromRecents),
indexOffset: sections.reduce((prev, {data}) => prev + data.length, 0),
});
sections.push({
title: this.props.translate('common.contacts'),
data: filterSelectedfromPersonalDetails,
shouldShow: !_.isEmpty(filterSelectedfromPersonalDetails),
indexOffset: sections.reduce((prev, {data}) => prev + data.length, 0),
});
This will not show No Result found as well as the selected users will not be shown the recent and contacts sections.
In both approaches, Selected users are always visible on the top as selected.
@robertjchen Whoops! This issue is 2 days overdue. Let's get this updated quick!
@robertjchen Still overdue 6 days?! Let's take care of this!
I don't agree that this is a bug, esp since the "duplicate" user is shown with a selected indicator. For example, if I were to add 15 people to a group, and I've added 12 – its likely I've forgotten that I already added igadamin. In this case, it's in fact useful to me to see visual feedback that the user was already added to the group.
Since this is for "adding new group", and not a new individual chat, it makes sense that we would assume that there are multiple users being added. So, showing the user again is actually a useful visual cue.
Ah, to clarify- the proposal is to remove the second entry from the list here, correct?

Yes. @robertjchen
@robertjchen Huh... This is 4 days overdue. Who can take care of this?
Still evaluating the two proposals, will let you know soon 👍
@robertjchen Huh... This is 4 days overdue. Who can take care of this?
@robertjchen Still overdue 6 days?! Let's take care of this!
@robertjchen 10 days overdue. Is anyone even seeing these? Hello?
@robertjchen 12 days overdue now... This issue's end is nigh!
This issue has not been updated in over 14 days. @robertjchen eroding to Weekly issue.
This issue has not been updated in over 15 days. @robertjchen eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
@robertjchen sorry – didnt see your response. I understand that the proposal is for the removal of the second entry. I was trying to say that the selected second entry confirms to the user that the person was in fact already added. When the list of "first entries"/selected users gets long, it can be difficult to immediately tell who is already added.
It does become confusing when there is no separation (such as a "recents" or "contacts" subtitle) between "selected users" and "search results"/contacts section. This is what it looks like when inviting users to a workspace: The lack of distinction between already selected invites and list of all contacts is confusing because it then looks like one long list. 
However, in the example of inviting a user to a group, I don't think it's as much of an issue since the "recents" subtitle acts as a divider to signal between the list of those who are about to be added and the list of the user's contacts. when the user searches for the same person again, it makes sense that we would filter their "list of contacts" and display the duplicate entry. It's fine because also indicate that the user has already selected them
Here is an example of how slack also double shows the selected user as way to prove that the user was already added:

Does that make sense?
If I agree that showing selected users in the search result is fine but it does look like an issue to the user. It has been reported by two contributors in our repo. Hypothetically saying, I believe if 2/250 think this is an issue then how many of ?/2500000 users can think the same?
let's talk about the image you referenced.

Here the UX is different in many ways. The main list of users that are selected is shown as boxes with a cross (robert). When you search the same user it is shown selected in the search list dropdown but you can't select it again and selecting it again does not deselect it.
There is a clear separation between the selected users and Search results. Search results are shown in the dropdown and preselected in the main form.
So I would say that would be a bad example for comparison. But it does emphasize that selected users and Searched users should be different.
So I think we should think about How can make a difference between the preselected and searched users on the list.
Maybe calling design team?
Thanks for the ping @K4tsuki. This is monthly but yeah @Expensify/design could you please give it another look?
Hmm I think I am a little confused about what is being asked here and where we are at with this one. Looking back through the comments, I would say I agree with @robertjchen's comment here.