HomePhabricator
Diffusion Comm 40e2da777056

[web] update toggleUser to use previouslySelectedUsers map if previously…

Description

[web] update toggleUser to use previouslySelectedUsers map if previously selected user is toggled

Summary:
PLEASE NOTE THAT THIS DIFF AND SUBSEQUENT DIFFS IN THIS STACK WILL NOT BE LANDED UNTIL MORE OF THE REDESIGN IS READY SINCE THIS WILL CAUSE REGRESSIONS IN PROD

As I was testing the new add users list, I ran into a case where the app would crash if I selected a user that I had searched for a user that was selected from the userStoreSearchResults cleared the search text, so this user was part of the previously selected users section and then unselected that user and then reselected the user again

This is because w/o the search text present mergedUserInfos does not have context regarding that searched user's user info. However, the previouslySelectedUsers still has the GlobalAccountUserInfo for that user stored.

We need to add a check to toggleUser that if the user toggled is a previously selected user, we should just grab the GlobalAccountUserInfo for that user from previouslySelectedUsers to prevent this crash from happening

Linear task: https://linear.app/comm/issue/ENG-5960/selected-users-section

Depends on D10822

Test Plan:
Please see demo video below

Reviewers: atul, inka

Reviewed By: atul

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D10823