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

[HOLD for payment 2023-04-27] [$1000] Pronouns search results are not arranged alphabetically #17223

Closed
6 tasks done
kavimuru opened this issue Apr 10, 2023 · 23 comments
Closed
6 tasks done
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented Apr 10, 2023

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


Action Performed:

  1. Open the app
  2. Open settings
  3. Open profile
  4. Open pronouns
  5. Search with '/' to get maximum results and observe the search results

Expected Result:

App should arrange pronouns search result alphabetically

Actual Result:

App does not arrange pronouns search result alphabetically eg: 'She / Her / Hers' are above 'Mer / Mers'

Workaround:

unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.2.97-2
Reproducible in staging?: y
Reproducible in production?: y
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
Notes/Photos/Videos: Any additional supporting documentation
Untitle1d

pronouns.not.alphabetical.issue.mp4

Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1681118476643659

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b466ff328355bffb
  • Upwork Job ID: 1646856150614585344
  • Last Price Increase: 2023-04-14
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 10, 2023
@MelvinBot
Copy link

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

@MelvinBot
Copy link

MelvinBot commented Apr 10, 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

@melvin-bot melvin-bot bot added the Overdue label Apr 13, 2023
@garrettmknight
Copy link
Contributor

Discussing internally to see if this was intentional for any reason before opening it up.

@melvin-bot melvin-bot bot removed the Overdue label Apr 13, 2023
@garrettmknight
Copy link
Contributor

Got agreement, let's make it alphabetical!

@garrettmknight garrettmknight added the External Added to denote the issue can be worked on by a contributor label Apr 14, 2023
@melvin-bot melvin-bot bot changed the title Pronouns search results are not arranged alphabetically [$1000] Pronouns search results are not arranged alphabetically Apr 14, 2023
@MelvinBot
Copy link

Job added to Upwork: https://www.upwork.com/jobs/~01b466ff328355bffb

@MelvinBot
Copy link

Current assignee @garrettmknight is eligible for the External assigner, not assigning anyone new.

@MelvinBot
Copy link

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 14, 2023
@tienifr
Copy link
Contributor

tienifr commented Apr 14, 2023

Proposal

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

Pronouns search results are not sorted in alphabetic order.

What is the root cause of that problem?

Currently the pronounsList in PronounsPage is not sorted, it's only filtered by user's search value.

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

Sort the filtered pronouns list in getFilteredSortedPronouns() function in alphabetic order.

return _.filter(this.pronounsList,
pronous => pronous.text.toLowerCase().indexOf(searchedValue.toLowerCase()) >= 0);

For example:

return _.chain(this.pronounsList)
            .filter(pronous => pronous.text.toLowerCase().indexOf(searchedValue.toLowerCase()) >= 0)
            .sortBy(pronous => pronous.text.toLocaleLowerCase())
            .value();

What alternative solutions did you explore? (Optional)

NA

Result

image

@Prince-Mendiratta
Copy link
Contributor

Proposal

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

In this issue, when the user enters the text that is common to all pronouns, that is, '/', then the whole list of pronouns is shown. This list however is not sorted alphabetically.

What is the root cause of that problem?

In the translate files, the keys for each pronoun is not sorted alphabetically. This causes the list to render without being sorted as well.

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

To solve this issue, three approaches can be considered:

Solution A
We can reorder the pronouns key in the translation files itself, which will render the pronouns alphabetically. This approach is not future proof though as in the future if anyone were to add a new pronoun, they would have to do so alphabetically and considering the direction this world is heading we might have hundreds of pronouns haha so might want to check for that case.

Solution B
We can use the _.sortBy function to sort the list before passing it to the _.filter function in the getFilteredPronouns method. This will happen for each input the user enters.

getFilteredPronouns() {

Solution C
We need to sort the whole list just once using the _.sortBy function in the loadPronouns method. This sorted list needs to be assigned to the this.pronounsList variable, which will ensure that all future operations are performed on the sorted list.

@PrashantMangukiya
Copy link
Contributor

Proposal

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

Pronouns search results are not arranged alphabetically.

What is the root cause of that problem?

We are filtering pronoun list via this function

getFilteredPronouns() {
const searchedValue = this.state.searchValue.trim();
if (searchedValue.length === 0) {
return [];
}
return _.filter(this.pronounsList,
pronous => pronous.text.toLowerCase().indexOf(searchedValue.toLowerCase()) >= 0);
}

We can see at line 72 we are returning list without any sorting. So this is the root cause of the problem.

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

We have to sort the pronoun list list as shown below

getFilteredPronouns() {
    const searchedValue = this.state.searchValue.trim();
    if (searchedValue.length === 0) {
        return [];
    }

   return _.chain(this.pronounsList)
            .filter(pronouns => pronouns.text.toLowerCase().indexOf(searchedValue.toLowerCase()) >= 0)
            .sortBy(pronoun => pronoun.text.toLowerCase())
            .value()
}

What alternative solutions did you explore? (Optional)

We can also sort pronoun list while we load it via loadPronouns() function here

loadPronouns() {
const currentPronouns = lodashGet(this.props.currentUserPersonalDetails, 'pronouns', '');
this.pronounsList = _.map(this.props.translate('pronouns'), (value, key) => {
const fullPronounKey = `${CONST.PRONOUNS.PREFIX}${key}`;
const isCurrentPronouns = fullPronounKey === currentPronouns;
if (isCurrentPronouns) {
this.initiallyFocusedOption = {
text: value,
keyForList: key,
};
}
return {
text: value,
value: fullPronounKey,
keyForList: key,
// Include the green checkmark icon to indicate the currently selected value
customIcon: isCurrentPronouns ? greenCheckmark : undefined,
// This property will make the currently selected value have bold text
boldStyle: isCurrentPronouns,
};
});
}

So updated code should be as shown under:

loadPronouns() {
    const currentPronouns = lodashGet(this.props.currentUserPersonalDetails, 'pronouns', '');
   
    // Make const
    const pronounsList = _.map(this.props.translate('pronouns'), (value, key) => {
         ...
    });
    
    // Add this line
    this.pronounsList = _.sortBy(pronounsList, pronoun => pronoun.text.toLowerCase());
}
Results
Web.mov

@MelvinBot
Copy link

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

@jayeshmangwani
Copy link
Contributor

Proposal

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

Pronouns search results are not sorted alphabetically

What is the root cause of that problem?

When we are returning the this.pronounsList at that time we are not sorting the list

this.pronounsList = _.map(this.props.translate('pronouns'), (value, key) => {
const fullPronounKey = `${CONST.PRONOUNS.PREFIX}${key}`;
const isCurrentPronouns = fullPronounKey === currentPronouns;
if (isCurrentPronouns) {
this.initiallyFocusedOption = {
text: value,
keyForList: key,
};
}
return {
text: value,
value: fullPronounKey,
keyForList: key,
// Include the green checkmark icon to indicate the currently selected value
customIcon: isCurrentPronouns ? greenCheckmark : undefined,
// This property will make the currently selected value have bold text
boldStyle: isCurrentPronouns,
};
});
}

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

we should use here sortBy function from the underscore like this

this.pronounsList = _.chain(this.props.translate('pronouns')) // <= ADD THIS LINE
    .map((value, key) => {
        const fullPronounKey = `${CONST.PRONOUNS.PREFIX}${key}`;
        const isCurrentPronouns = fullPronounKey === currentPronouns;

        if (isCurrentPronouns) {
            this.initiallyFocusedOption = {
                text: value,
                keyForList: key,
            };
        }

        return {
            text: value,
            value: fullPronounKey,
            keyForList: key,

            // Include the green checkmark icon to indicate the currently selected value
            customIcon: isCurrentPronouns ? greenCheckmark : undefined,

            // This property will make the currently selected value have bold text
            boldStyle: isCurrentPronouns,
        };
    })
    .sortBy(prounce => prounce.text) // <= ADD THIS LINE
    .value(); // <= ADD THIS LINE

What alternative solutions did you explore? (Optional)

none

@fedirjh
Copy link
Contributor

fedirjh commented Apr 14, 2023

Thanks everyone for the proposals , all proposals are quite similar. IMO by sorting the pronouns list in the loadPronouns function, we ensure that the sorted list is always available and any subsequent filtering operations are performed on the already sorted list. This approach would also avoid unnecessary sorting operations in the getFilteredPronouns function, which would improve performance.

Based on this , we can proceed with @Prince-Mendiratta's Proposal : Solution C.

@danieldoglas All yours.

🎀 👀 🎀 C+ reviewed

@melvin-bot melvin-bot bot added the Overdue label Apr 17, 2023
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 17, 2023
@MelvinBot
Copy link

📣 @Prince-Mendiratta You have been assigned to this job by @garrettmknight!
Please apply to this job in Upwork and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@garrettmknight
Copy link
Contributor

Everyone has offers.

@melvin-bot melvin-bot bot added the Reviewing Has a PR in review label Apr 18, 2023
@Prince-Mendiratta
Copy link
Contributor

PR is up for review!

Accepted the offer on upwork.

Thanks!

cc @fedirjh

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Apr 20, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Pronouns search results are not arranged alphabetically [HOLD for payment 2023-04-27] [$1000] Pronouns search results are not arranged alphabetically Apr 20, 2023
@MelvinBot
Copy link

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Apr 20, 2023
@MelvinBot
Copy link

MelvinBot commented Apr 20, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.2-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-04-27. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@MelvinBot
Copy link

MelvinBot commented Apr 20, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@fedirjh] The PR that introduced the bug has been identified. Link to the PR:
  • [@fedirjh] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@fedirjh] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@garrettmknight] Determine if we should create a regression test for this bug.
  • [@fedirjh] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@garrettmknight] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@garrettmknight garrettmknight removed their assignment Apr 21, 2023
@garrettmknight garrettmknight added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Apr 21, 2023
@garrettmknight
Copy link
Contributor

garrettmknight commented Apr 21, 2023

Reassigning since I'm OOO next week when this should be paid assuming no regressions.

@MelvinBot
Copy link

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 21, 2023
@Expensify Expensify deleted a comment from MelvinBot Apr 21, 2023
@garrettmknight garrettmknight added Weekly KSv2 and removed Daily KSv2 labels Apr 21, 2023
@fedirjh
Copy link
Contributor

fedirjh commented Apr 22, 2023

  • The PR that introduced the bug has been identified. Link to the PR: New Pronouns page #12301
  • The offending PR has been commented on : N/A It appears to be more aligned with a feature request rather than a regression.
  • A discussion in #expensify-bugs has been started: N/A this was a new page, code didn't exist before that
  • Determine if we should create a regression test for this bug: N/A This may not be critical enough to justify the effort of creating a new test case

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 27, 2023
@puneetlath
Copy link
Contributor

All paid. Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

10 participants