Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.13k stars 2.63k forks source link

[$250] Workspace member - Hidden admin appears in the members list after changing contact method #44705

Open lanitochka17 opened 1 week ago

lanitochka17 commented 1 week ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.3-3 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Issue reported by: Applause - Intrnal Team

Action Performed:

Precondition: Use Gmail account to login

  1. Create workspace
  2. Go to WS members - only owner is shown
  3. Go to Account settings > Profile > Contact method
  4. Add new email as a contact method
  5. Verify new added email
  6. Set added email as default
  7. Go to WS > Members

Expected Result:

Only owner (with a new email) shown in the members list

Actual Result:

Second member as Hidden (Admin) appears in the list. When user clicks on it 'Hmm.. it's not here page' opens

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/78819774/7fbdf5ea-578d-4742-9ac8-9405d84f43b2

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~014a16dfba8ca4a44e
  • Upwork Job ID: 1810351284921394393
  • Last Price Increase: 2024-07-08
  • Automatic offers:
    • rayane-djouah | Reviewer | 103066635
Issue OwnerCurrent Issue Owner: @rayane-djouah
melvin-bot[bot] commented 1 week ago

Triggered auto assignment to @anmurali (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

devguest07 commented 1 week ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

Workspace member - Hidden admin appears in the members list after changing contact method

What is the root cause of that problem?

After adding a second email as a contact method and setting it as the default, the policy.employeeList will include both the old and new emails as contact methods.

https://github.com/Expensify/App/blob/49a53343dff25895f5b9409e87ff9e5513049d29/src/pages/workspace/WorkspaceMembersPage.tsx#L322

What changes do you think we should make in order to solve the problem?

To resolve this issue, it's preferable to reference the data within loginList, which contains all login email addresses. For each entry in policy?.employeeList, if the email exists in loginList and is not equal to policy.owner, it should not be displayed.

// Skip emails that exist in loginList and are not equal to policy.owner 
if (loginList.includes(email) && email !== policy?.owner) { return; }

Note: We can consider using policy.owner to determine if an email should be excluded. The main goal here is to prevent any secondary email that exists in loginList from being displayed.

What alternative solutions did you explore?

bernhardoj commented 1 week ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

Owner account and Hidden user shows after updating default contact method.

What is the root cause of that problem?

When we update the default contact method, we optimistically update the policy owner to the new default contact method. https://github.com/Expensify/App/blob/5ab6be6ecb01d6398eb2503dbd3f6dad60d6638f/src/libs/actions/User.ts#L879-L889

However, the previous contact method is still listed in the policy employeeList. The reason the previous contact method shows as Hidden is that we also optimistically update the personal details of the user to the new contact method (email), so the app can't find the previous personal detail anymore. https://github.com/Expensify/App/blob/5ab6be6ecb01d6398eb2503dbd3f6dad60d6638f/src/libs/actions/User.ts#L818-L825

The badge shows admin because it's not the owner anymore.

When we open the ws members page, the BE response will merge the new contact method to the ws member list.

What changes do you think we should make in order to solve the problem?

Optimistically remove the previous contact method and add the new one to the ws member list. https://github.com/Expensify/App/blob/5ab6be6ecb01d6398eb2503dbd3f6dad60d6638f/src/libs/actions/User.ts#L879-L897

employeeList: {
    [oldDefaultContactMethod]: null,
    [newDefaultContactMethod]: {
        role: 'admin'
    },
},

(and revert it when fails)

melvin-bot[bot] commented 1 week ago

@anmurali Whoops! This issue is 2 days overdue. Let's get this updated quick!

anmurali commented 6 days ago

Can reproduce on staging

melvin-bot[bot] commented 6 days ago

Job added to Upwork: https://www.upwork.com/jobs/~014a16dfba8ca4a44e

melvin-bot[bot] commented 6 days ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @rayane-djouah (External)

rayane-djouah commented 5 days ago

Can reproduce on staging 👍

https://github.com/Expensify/App/assets/77965000/f22b42b2-953c-4be2-bc68-71ed68a2fb47

Reviewing proposals...

rayane-djouah commented 5 days ago

@bernhardoj's proposal LGTM

:ribbon::eyes::ribbon: C+ reviewed

melvin-bot[bot] commented 5 days ago

Triggered auto assignment to @blimpich, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] commented 4 days ago

📣 @rayane-djouah 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job

bernhardoj commented 4 days ago

PR is ready

cc: @rayane-djouah