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 2024-06-06] [$250] Tags - After deleting a Tag, the select button is not showing the correct amount #42271

Closed
5 of 6 tasks
izarutskaya opened this issue May 16, 2024 · 26 comments
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

@izarutskaya
Copy link

izarutskaya commented May 16, 2024

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
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 16, 2024
Copy link

melvin-bot bot commented May 16, 2024

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.

@izarutskaya
Copy link
Author

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

@Krishna2323
Copy link
Contributor

Krishna2323 commented May 16, 2024

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)

@stephanieelliott stephanieelliott added the External Added to denote the issue can be worked on by a contributor label May 17, 2024
Copy link

melvin-bot bot commented May 17, 2024

Job added to Upwork: https://www.upwork.com/jobs/~010953527677d8e414

@melvin-bot melvin-bot bot 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 May 17, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 17, 2024
Copy link

melvin-bot bot commented May 17, 2024

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

@cretadn22
Copy link
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.

@RandikaSilva
Copy link

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

Copy link

melvin-bot bot commented May 18, 2024

📣 @RandikaSilva! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@RandikaSilva
Copy link

Contributor details
Expensify account email: mlasitharandika@gmail.com
Upwork Profile Link: <Upwork Profile>

@thesahindia
Copy link
Member

@Krishna2323's proposal looks good to me!

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented May 19, 2024

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

@cretadn22
Copy link
Contributor

cretadn22 commented May 19, 2024

@thesahindia The selected proposal doesn't work in offline. Could you check again? As I mentioned in my proposal

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

@Krishna2323
Copy link
Contributor

@cretadn22, I don't think your proposal is different from mine.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label May 20, 2024
Copy link

melvin-bot bot commented May 20, 2024

📣 @Krishna2323 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer 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 📖

@stephanieelliott
Copy link
Contributor

Hey @Krishna2323, can you update on when we can expect a PR?

@Krishna2323
Copy link
Contributor

Raising PR in few minutes.

@melvin-bot melvin-bot bot added the Weekly KSv2 label May 22, 2024
@Krishna2323
Copy link
Contributor

@thesahindia, PR ready for review.

@stephanieelliott
Copy link
Contributor

PR was merged earlier today

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels May 30, 2024
@melvin-bot melvin-bot bot changed the title [$250] Tags - After deleting a Tag, the select button is not showing the correct amount [HOLD for payment 2024-06-06] [$250] Tags - After deleting a Tag, the select button is not showing the correct amount May 30, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 30, 2024
Copy link

melvin-bot bot commented May 30, 2024

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

Copy link

melvin-bot bot commented May 30, 2024

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:

Copy link

melvin-bot bot commented May 30, 2024

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:

@stephanieelliott
Copy link
Contributor

Hey @thesahindia can you please complete the BZ checklist?

@stephanieelliott
Copy link
Contributor

Summarizing payment on this issue:

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

@thesahindia
Copy link
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"

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Jun 6, 2024
@stephanieelliott
Copy link
Contributor

Thanks @thesahindia! Issue for regression test created here: https://github.com/Expensify/Expensify/issues/402937

@JmillsExpensify
Copy link

$250 approved for @thesahindia

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
Archived in project
Development

No branches or pull requests

8 participants