Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact method needs reload to correct the order #30038

Closed
2 of 6 tasks
kavimuru opened this issue Oct 19, 2023 · 7 comments
Closed
2 of 6 tasks

Contact method needs reload to correct the order #30038

kavimuru opened this issue Oct 19, 2023 · 7 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Needs Reproduction Reproducible steps needed

Comments

@kavimuru
Copy link

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number:
Reproducible in staging?: needs reproduction
Reproducible in production?: needs reproduction
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695036320538419

Action Performed:

Precondition: user should have at least 2 contact methods added

  1. Open the app
  2. Open settings->profile->contact method
  3. Click on New contact method
  4. Add contact method which will not occupy last position alphabetically in currrent list
  5. Observe that it is displayed last after adding
  6. Reload and observe that now app rectifies the order

Expected Result:

App should order contact method alphabetically as soon as we add the contact

Actual Result:

App need reload after adding contact method to order it alphabetically

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
reload.needed.to.arrange.alphabetically.contact.method.mp4
MacOS: Desktop

View all open jobs on GitHub

@DylanDylann
Copy link
Contributor

Proposal

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

  • Contact method needs reloaded to correct the order

What is the root cause of that problem?

const sortedLoginNames = _.sortBy(loginNames, (loginName) => (props.loginList[loginName].partnerUserID === props.session.email ? 0 : 1));

  • Currently, our sort function does not work properly. The sortBy method in underscore can only have one iteratee (loginName) => (props.loginList[loginName].partnerUserID === props.session.email ? 0 : 1), so it leads to the bug
  • After refreshing page, API ReconnectApp will return the loginList with the correct order, that lead to the behavior mentioned in the bug "needs reloaded to correct the order""

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

  • We can use the sortBy in lodash - that allow more than one iteratee function, for example:
     const sortedLoginNames = lodashSortBy(loginNames, [(loginName) => props.loginList[loginName].partnerUserID === props.session.email ? 0 : 1, (item) => item]);
  • In the above, we are putting the loginName that matches the first iteratee to the top and then apply the second iteratee for the rest

What alternative solutions did you explore? (Optional)

  • NA

Result

Screencast.from.21-09-2023.07.03.03.webm

@c3024
Copy link
Contributor

c3024 commented Oct 19, 2023

Proposal

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

Added contact method is not placed in sorted order after adding a contact method.

What is the root cause of that problem?

Here we are only keeping the default contact method at top and not changing the order of the logins for others.

const sortedLoginNames = _.sortBy(loginNames, (loginName) => (props.loginList[loginName].partnerUserID === props.session.email ? 0 : 1));

When we refresh the list received from BE has the login list sorted so the list is sorted.

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

We can sort the remaining contact methods in this way

const sortedLoginNames = _.sortBy(loginNames, (loginName) => [
        props.loginList[loginName].partnerUserID !== props.session.email, // true (1) for non-matching, and false (0) for matching, so matching ones come first
        loginName.toLowerCase() // case-insensitive lexicographic sort for the rest
      ]);

What alternative solutions did you explore? (Optional)

I think the ideal order should be

  1. Default contact
  2. Validated logins sorted by login name
  3. Unvalidated logins sorted by login name
    If we want this order we use
      const sortedLoginNames = _.sortBy(loginNames, (loginName) => {
        const user = props.loginList[loginName];
        return [
          user.partnerUserID !== props.session.email, // First: Matching partnerUserID comes first
          !user.validatedDate, // Second: Non-empty validated comes first
          loginName.toLowerCase() // Third: Sorted by loginName
        ];
      });

@kavimuru kavimuru added the Needs Reproduction Reproducible steps needed label Oct 19, 2023
@melvin-bot melvin-bot bot added the Daily KSv2 label Oct 19, 2023
@kavimuru kavimuru added Bug Something is broken. Auto assigns a BugZero manager. and removed Daily KSv2 labels Oct 19, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 19, 2023

Triggered auto assignment to @mallenexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added the Daily KSv2 label Oct 19, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 19, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@kavimuru
Copy link
Author

Issue not reproducible by QA team

@DylanDylann
Copy link
Contributor

I still can reproduce

Screencast.from.20-10-2023.11.54.53.webm

@mallenexpensify
Copy link
Contributor

  1. It's not reordering for me
  2. I think this would fall under 'dynamically updating' which I don't think we're actively working on. I reopened that tracking issue and am adding this to that list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Needs Reproduction Reproducible steps needed
Projects
None yet
Development

No branches or pull requests

4 participants