Skip to content

[HOLD for payment 2024-06-06] [$250] Tags - After deleting a Tag, the select button is not showing the correct amount #42271

Closed

Description

@izarutskaya

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: v1.4.74-1
Reproducible in staging?: Y
Reproducible in production?: Y
Found when validating PR : #42086
Email or phone of affected tester (no customers): applausetester+emilio@applause.expensifail.com
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

  1. Open the New Expensify App
  2. Sign into a valid account
  3. Click on WS > Tags (Enable if needed)
  4. Add a couple of tags (Two are fine)
  5. Select the two tags (Notice it says 2 are selected)
  6. Delete one of the tags
  7. Add a new tag quickly so there are 2 again
  8. Select "All" button to select both tags

Expected Result:

User expects the correct number of tags to be shown in the selected area

Actual Result:

The incorrect number of tags is shown, "3 selected" is shown instead of "2 selected"

Workaround:

Unknown

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

Bug6482146_1715817630755.Incorrect_number_of_tags_are_shown_in_selection_.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~010953527677d8e414
  • Upwork Job ID: 1791581466256613376
  • Last Price Increase: 2024-05-17
  • Automatic offers:
    • Krishna2323 | Contributor | 0
Issue OwnerCurrent Issue Owner: @stephanieelliott

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 16, 2024
  2. melvin-bot commented on May 16, 2024

    @melvin-bot

    Triggered auto assignment to @stephanieelliott (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.

  3. izarutskaya commented on May 16, 2024

    @izarutskaya
    Author

    We think this issue might be related to the #collect project.

  4. Krishna2323 commented on May 16, 2024

    @Krishna2323
    Contributor

    Proposal

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

    Tags - After deleting a Tag, the select button is not showing the correct amount

    What is the root cause of that problem?

    We are not filtering out tags with pending action of delete.

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

    Filter out tags with pending action of delete in toggleAllTags callback.

    const toggleAllTags = () => {
    const isAllSelected = tagList.every((tag) => !!selectedTags[tag.value]);
    setSelectedTags(isAllSelected ? {} : Object.fromEntries(tagList.map((item) => [item.value, true])));
    };

    We apply same logic as in WorkspaceCategoriesPage.

    const toggleAllCategories = () => {
    const availableCategories = categoryList.filter((category) => category.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
    const isAllSelected = availableCategories.length === Object.keys(selectedCategories).length;
    setSelectedCategories(isAllSelected ? {} : Object.fromEntries(availableCategories.map((item) => [item.keyForList, true])));
    };

    What alternative solutions did you explore? (Optional)

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on May 17, 2024
  6. melvin-bot commented on May 17, 2024

    @melvin-bot
  7. changed the title [-]Tags - After deleting a Tag, the select button is not showing the correct amount[/-] [+][$250] Tags - After deleting a Tag, the select button is not showing the correct amount[/+] on May 17, 2024
  8. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 17, 2024
  9. melvin-bot commented on May 17, 2024

    @melvin-bot

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

  10. cretadn22 commented on May 18, 2024

    @cretadn22
    Contributor

    Proposal

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

    Tags - Upon removal of a tag, the select button fails to display the accurate quantity

    What is the root cause of that problem?

    const toggleAllTags = () => {
    const isAllSelected = tagList.every((tag) => !!selectedTags[tag.value]);
    setSelectedTags(isAllSelected ? {} : Object.fromEntries(tagList.map((item) => [item.value, true])));
    };

    The toggleAllTags function does not properly filter out tags with pending delete actions. And the logic for checking isAllSelected also be wrong

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

    It's necessary to filter out tags that have pending delete actions. And then we also need to update the logic for checking isAllSelected, it's crucial to filter out tags with pending delete actions to maintain correct functionality when offline

    const notPendingDeleteTag = tagList.filter((item)=> item.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE)
    const isAllSelected = notPendingDeleteTag.every((tag) => !!selectedTags[tag.value]);
    setSelectedTags(isAllSelected ? {} : Object.fromEntries(notPendingDeleteTag.map((item) => [item.value, true])));
    

    The same fix should be applied to other pages as well

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  11. RandikaSilva commented on May 18, 2024

    @RandikaSilva

    Proposal: Fix for Incorrect Tag Count After Deletion

    Overview:
    The current issue arises because tags pending deletion are still considered in the selection logic, leading to an incorrect tag count.

    Technical Explanation:
    To address this issue, I will modify the toggleAllTags function to exclude tags that have a pendingAction set to CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE.

    Proposed Code Change:
    The revised toggleAllTags function will look as follows:

    const toggleAllTags = () => {
        const isAllSelected = tagList.every((tag) => selectedTags[tag.value] && tag.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
        setSelectedTags(isAllSelected ? {} : Object.fromEntries(tagList.filter(tag => tag.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE).map((item) => [item.value, true])));
    };

    Note

    This update ensures that tags pending deletion are not considered when determining if all tags are selected and when toggling all tags. I recommend applying the same correction to other pages.

    After changes done:

    Screen.Recording.2024-05-19.at.3.14.38.AM.mov
  12. 22 remaining items

  13. melvin-bot commented on May 30, 2024

    @melvin-bot

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

  14. melvin-bot commented on May 30, 2024

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.77-11 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 2024-06-06. 🎊

    For reference, here are some details about the assignees on this issue:

  15. melvin-bot commented on May 30, 2024

    @melvin-bot

    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:

    • [@thesahindia] The PR that introduced the bug has been identified. Link to the PR:
    • [@thesahindia] 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:
    • [@thesahindia] 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:
    • [@thesahindia] Determine if we should create a regression test for this bug.
    • [@thesahindia] 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.
    • [@stephanieelliott] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  16. stephanieelliott commented on Jun 4, 2024

    @stephanieelliott
    Contributor

    Hey @thesahindia can you please complete the BZ checklist?

  17. stephanieelliott commented on Jun 4, 2024

    @stephanieelliott
    Contributor

    Summarizing payment on this issue:

    Upwork job is here: https://www.upwork.com/jobs/~010953527677d8e414

  18. thesahindia commented on Jun 4, 2024

    @thesahindia
    Member

    This case should have been handled in #37621 but it was missed.

    We should add a general test case for all similar instances -

    1. Go to any page that has a list (example: Workspace tags page)
    2. Make sure there are at least 2 list items
    3. Click the top most checkbox to select all items
    4. Verify it says "2 selected" at the top right corner
    5. Go offline
    6. Delete one item
    7. Again select all the items
    8. Verify it says "1 selected"
  19. stephanieelliott commented on Jun 7, 2024

    @stephanieelliott
    Contributor
  20. JmillsExpensify commented on Jun 17, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @thesahindia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions