Skip to content

[Due for payment 2025-05-20] [$250] Categories - Checkmark appears briefly next to the toggle after exiting selection mode #61823

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

Closed
2 of 8 tasks
mitarachim opened this issue May 10, 2025 · 26 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@mitarachim
Copy link

mitarachim commented May 10, 2025

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: 9.1.43-7
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Samsung Galaxy Z Fold 4 / Android 14
App Component: Workspace Settings

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Categories.
  3. Long press on any category.
  4. Tap Select.
  5. Tap app back button to exit selection mode.

Expected Result:

Checkmark will not appear next to the toggle after exiting selection mode.

Actual Result:

Checkmark appears briefly next to the toggle after exiting selection mode.

This issue also happens to Members, Tags, Taxes, Per diem etc.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Image
Bug6827149_1746862380989.Screen_Recording_20250510_152731_Chrome.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021922117839038973532
  • Upwork Job ID: 1922117839038973532
  • Last Price Increase: 2025-05-13
  • Automatic offers:
    • thelullabyy | Contributor | 107282602
    • allgandalf | Contributor | 107286457
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @greg-schroeder
@mitarachim mitarachim added DeployBlockerCash This issue or pull request should block deployment Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. DeployBlocker Indicates it should block deploying the API labels May 10, 2025
Copy link

melvin-bot bot commented May 10, 2025

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

Copy link

melvin-bot bot commented May 10, 2025

Triggered auto assignment to @techievivek (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented May 10, 2025

💬 A slack conversation has been started in #expensify-open-source

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels May 10, 2025
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@techievivek
Copy link
Contributor

@daledah Could this also be related to your PR here #60488? Do you mind taking a look.

@greg-schroeder
Copy link
Contributor

Hey @techievivek - do you think @daledah and @thesahindia should be assigned to this given they worked on #60488?

@francoisl francoisl added the External Added to denote the issue can be worked on by a contributor label May 13, 2025
@melvin-bot melvin-bot bot changed the title Categories - Checkmark appears briefly next to the toggle after exiting selection mode [$250] Categories - Checkmark appears briefly next to the toggle after exiting selection mode May 13, 2025
Copy link

melvin-bot bot commented May 13, 2025

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 13, 2025
Copy link

melvin-bot bot commented May 13, 2025

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

@francoisl
Copy link
Contributor

Opening to external contributors to help speed things up with getting a resolution for this.
For context, we already know the issue is coming from #60488.

@thelullabyy
Copy link
Contributor

thelullabyy commented May 13, 2025

Proposal

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

Checkmark appears briefly next to the toggle after exiting selection mode.

What is the root cause of that problem?

When clicking the back button on selection mode, we will turn off the selection mode and reset the selected categories

setSelectedCategories([]);
turnOffMobileSelectionMode();

This bug happens because the App turns off selection mode completely before resetting the selected categories is done

{!canSelectMultiple && !!item.isSelected && !rightHandSideComponent && (
<View
style={[styles.flexRow, styles.alignItemsCenter, styles.ml3]}
accessible={false}
>
<View>
<Icon
src={Expensicons.Checkmark}
fill={theme.success}

--> canSelectMultiple is false while item.selected still be true

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

We need to make sure the selected categories is cleared before turning off the selection mode by using runAfterInteractions

                            setSelectedCategories([]);
                            InteractionManager.runAfterInteractions(() => {
                                turnOffMobileSelectionMode();
                            });

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA

What alternative solutions did you explore? (Optional)

Because the checkmark on the right-hand side shouldn't be used in this page, we can introduce a new prop on BaseListItem Component called shouldUseDefaultRightHandSideCheckmark and pass this prop is false to prevent rendering this checkmark unnecessarily

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.

@bernhardoj
Copy link
Contributor

Proposal

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

Checkmark appears briefly when closing the selection mode.

What is the root cause of that problem?

In BaseListItem, if canSelectMultiple is false but the item is selected, we show the checkmark icon.

{!canSelectMultiple && !!item.isSelected && !rightHandSideComponent && (
<View
style={[styles.flexRow, styles.alignItemsCenter, styles.ml3]}
accessible={false}
>
<View>
<Icon
src={Expensicons.Checkmark}
fill={theme.success}
/>
</View>
</View>
)}

When we close the selection mode, canSelectMultiple is set to false, but the item is still selected.

onBackButtonPress={() => {
if (selectionMode?.isEnabled) {
setSelectedCategories([]);
turnOffMobileSelectionMode();
return;
}

The selectedCategories state itself is immediately cleared, and the isSelected value here of categoryList is false.

isSelected: selectedCategories.includes(value.name) && canSelectMultiple,

However, we don't show the categoryList. Instead, we use the filtered one, and the filtered one is updated inside a useEffect, which is "deferred" to the next render.

const [inputValue, setInputValue, filteredCategoryList] = useSearchResults(categoryList, filterCategory, sortCategories);

useEffect(() => {
startTransition(() => {
const normalizedSearchQuery = inputValue.trim().toLowerCase();
const filtered = normalizedSearchQuery.length ? data.filter((item) => filterData(item, normalizedSearchQuery)) : data;
const sorted = sortData(filtered);
setResult(sorted);
});
}, [data, filterData, inputValue, sortData]);

So, canSelectMultiple has already been updated, but the item list is late.

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

We can defer the turnOffMobileSelectionMode calls too so it's only called after filteredCategoryList is updated. shouldTurnOffMobileSelectionMode is set to true when pressing the back button.

onBackButtonPress={() => {
if (selectionMode?.isEnabled) {
setSelectedCategories([]);
turnOffMobileSelectionMode();
return;
}

useEffect(() => {
    if (shouldTurnOffMobileSelectionMode.current) {
        turnOffMobileSelectionMode();
        shouldTurnOffMobileSelectionMode.current = false;
    }
}, [filteredCategoryList]);

But this approach only handles the app back button only. turnOffMobileSelectionMode is also called when pressing the android back button. We can make it work, but it's not a clean solution.

const useSearchBackPress: UseSearchBackPress = ({onClearSelection, onNavigationCallBack}) => {
const [selectionMode] = useOnyx(ONYXKEYS.MOBILE_SELECTION_MODE);
useFocusEffect(
useCallback(() => {
const onBackPress = () => {
if (selectionMode?.isEnabled) {
onClearSelection();
turnOffMobileSelectionMode();
return true;
}

The other options are:

  1. Put canSelectMultiple as the item attribute instead of the list props.
!item.canSelectMultiple && !!item.isSelected

{!canSelectMultiple && !!item.isSelected && !rightHandSideComponent && (
<View
style={[styles.flexRow, styles.alignItemsCenter, styles.ml3]}
accessible={false}
>

This way, canSelectMultiple is only updated when the list item is updated too.

  1. Rework the selected attribute. Instead of putting the isSelected to the item attribute, we can have a new props called getIsSelected which returns either true or false.
getIsSelected={(value) => selectedCategories.includes(value.name) && canSelectMultiple}

This way, both canSelectMultiple and selected state are coming from the props and do not depend on the filtered list state.

We need to fix other WS pages too.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N/A

@DylanDylann
Copy link
Contributor

@thelullabyy your alternative solution looks good to me. I think it is a safe and effective way to solve this bug in many places

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented May 13, 2025

Current assignee @techievivek is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

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

melvin-bot bot commented May 13, 2025

📣 @thelullabyy 🎉 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 📖

@mountiny
Copy link
Contributor

@thelullabyy we need this fix asap, are you able to push the PR?

@thelullabyy
Copy link
Contributor

The PR will be up soon, I am working on it

Copy link

melvin-bot bot commented May 13, 2025

📣 @allgandalf 🎉 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 📖

@mountiny
Copy link
Contributor

@thelullabyy What is your ETA? you have been assigned for 6 hours

@mountiny
Copy link
Contributor

@allgandalf can help raise the PR quicker if you are not available

@thelullabyy
Copy link
Contributor

The PR will be up in 30 minutes

@mountiny
Copy link
Contributor

Are you in Slack, lets also chat there for faster resolution @thelullabyy

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Hourly KSv2 labels May 13, 2025
@mountiny mountiny removed the DeployBlockerCash This issue or pull request should block deployment label May 13, 2025
@techievivek
Copy link
Contributor

Requested for a re-test here https://expensify.slack.com/archives/C9YU7BX5M/p1747146169329929, we can close it once we have confirmed this is fixed.

@IuliiaHerets
Copy link

@techievivek Issue was fixed for us too

Screen_Recording_20250513_225520_Chrome.mp4

@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 13, 2025
@melvin-bot melvin-bot bot changed the title [$250] Categories - Checkmark appears briefly next to the toggle after exiting selection mode [Due for payment 2025-05-20] [$250] Categories - Checkmark appears briefly next to the toggle after exiting selection mode May 13, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 13, 2025
Copy link

melvin-bot bot commented May 13, 2025

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

Copy link

melvin-bot bot commented May 13, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.44-8 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 2025-05-20. 🎊

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

Copy link

melvin-bot bot commented May 13, 2025

@allgandalf / @DylanDylann @greg-schroeder @allgandalf / @DylanDylann The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

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. Engineering External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
None yet
Development

No branches or pull requests

10 participants