Skip to content

[Due for payment 2025-04-28] [Better Expense Report View] Checkbox state is not reset after switching tabs #59833

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 18 tasks
lanitochka17 opened this issue Apr 8, 2025 · 29 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 Engineering

Comments

@lanitochka17
Copy link

lanitochka17 commented Apr 8, 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.24-2
Reproducible in staging?: Y
Reproducible in production?: N
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

  • Log in with Expensifail account
  1. Go to staging.new.expensify.com
  2. Create a workspace
  3. Go to workspace chat
  4. Submit an expense
  5. Go to Reports
  6. Go to Expense Reports
  7. Click on the expense report from Step 4
  8. Select the checkbox
  9. Go to another tab (Expense in Reports or Inbox)
  10. Go back to Reports > Expense Reports
  11. Click on the same expense preview in Step 7

Expected Result:

The checkbox state will be reset after switching tabs

Actual Result:

The checkbox state is not reset after switching tabs

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop
Platforms Tested: On which of our officially supported platforms was this issue tested:
  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6796031_1744118095456.20250408_210121.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @DylanDylann
@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Apr 8, 2025
Copy link

melvin-bot bot commented Apr 8, 2025

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

Copy link

melvin-bot bot commented Apr 8, 2025

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

Copy link
Contributor

github-actions bot commented Apr 8, 2025

👋 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.

@mountiny mountiny changed the title Expense Reports - Checkbox state is not reset after switching tabs [Better Expense Report View] Checkbox state is not reset after switching tabs Apr 8, 2025
@mountiny mountiny added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Apr 8, 2025
@mountiny mountiny moved this to Second Cohort - CRITICAL in [#whatsnext] #migrate Apr 8, 2025
@mountiny
Copy link
Contributor

mountiny commented Apr 8, 2025

this is behind beta

@samranahm
Copy link
Contributor

samranahm commented Apr 8, 2025

Proposal

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

Checkbox state is not reset after switching tabs

What is the root cause of that problem?

Here

const {selectedTransactionsID, setSelectedTransactionsID, toggleTransaction, isTransactionSelected} = useMoneyRequestReportContext(report.reportID);

setSelectedTransactionsID does not update when user navigate back from MoneyRequestReportTransactionList or switch the tabs

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

we should add useFocusEffect in MoneyRequestReportTransactionList that will reset the setSelectedTransactionsID when user switch the tabs

useFocusEffect(
    useCallback(() => {    
        return () => {
            setSelectedTransactionsID([]);
        };
    }, []),
); 

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

N/A

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.

Results

new-833.mp4

@mountiny
Copy link
Contributor

mountiny commented Apr 8, 2025

@allgandalf @DylanDylann do you want to review the proposal please?

@ChavdaSachin
Copy link
Contributor

ChavdaSachin commented Apr 8, 2025

Proposal

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

[Better Expense Report View] Checkbox state is not reset after switching tabs

What is the root cause of that problem?

On search > expenseReportPage useMoneyRequestReportContext hook is used to keep track of selections and hence selections does not clear after page reload/ tab change.
And no additional mechanism no clear selection for the same is used here.

const {selectedTransactionsID, setSelectedTransactionsID, toggleTransaction, isTransactionSelected} = useMoneyRequestReportContext(report.reportID);

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

Generally app has tendency to clear the selection on any navigation with only one exception - app does not clear selection when user clicks a list item and item opens in RHP.

For example.

  1. open search page and go to expenses select few expense using checkbox.
  2. now click on any of the expense from list and the expense details would open in RHP.
  3. now close the RHP.
  4. Notice selections are not cleared.
  5. now keep few expenses selected and navigate to any other search tab ie. Expense Reports.
  6. Navigate back to Expenses tab.
  7. Notice selection is cleared.

Reference Video

Screen.Recording.2025-04-08.at.10.35.01.PM.mov

We already have a hook for the above situation - useCleanupSelectedOptions.
Add following code snippet here.

    const cleanupSelectedOption = useCallback(() => setSelectedTransactionsID([]), []);
    useCleanupSelectedOptions(cleanupSelectedOption);

const {selectedTransactionsID, setSelectedTransactionsID, toggleTransaction, isTransactionSelected} = useMoneyRequestReportContext(report.reportID);

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)

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.

@allgandalf
Copy link
Contributor

@mountiny , this bug was already reported during PR testing:

We decided to fix this in a follow up:

c.c. @jnowakow

@mountiny
Copy link
Contributor

mountiny commented Apr 8, 2025

We could handle it externally maybe what do you think @allgandalf @jnowakow

@allgandalf
Copy link
Contributor

@jnowakow said:

it should be fixed in follow up because it won't be that easy.

So maybe he is seeing a core issue here with the new preview which i am not, so i will wait for him to comment before opening this up to the community

@mountiny
Copy link
Contributor

mountiny commented Apr 8, 2025

yep gonna wait for confirmation

@jnowakow
Copy link
Contributor

jnowakow commented Apr 9, 2025

Simple useFocusEffect from #59833 (comment) won't work because it will clean selected items when RHP is opened.

Solution from #59833 (comment) is almost good but doesn't work when navigating back using chevron:

close.mov

@nkdengineer
Copy link
Contributor

Proposal

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

The checkbox state is not reset after switching tabs

What is the root cause of that problem?

The data is stored in the context, and we don't have the logic to clear the transaction when the page is blurred/unmounted

const {selectedTransactionsID, setSelectedTransactionsID, toggleTransaction, isTransactionSelected} = useMoneyRequestReportContext(report.reportID);

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

  1. We can use useCleanupSelectedOptions hook to clear the data when the page is blurred. But it will not resolve this bug because when we click on the back button, the page is unmounted, and this hook doesn't cover this case.
const cleanupSelectedOption = useCallback(() => setSelectedTransactionsID([]), []);
useCleanupSelectedOptions(cleanupSelectedOption);

const {selectedTransactionsID, setSelectedTransactionsID, toggleTransaction, isTransactionSelected} = useMoneyRequestReportContext(report.reportID);

  1. To fix the bug above, add a new useEffect to call the clean function again if the component is unmounted in the hook
const cleanupFunctionRef = useRef(cleanupFunction);
useEffect(() => {
    cleanupFunctionRef.current = cleanupFunction;
}, [cleanupFunction]);

useEffect(() => {
    return () => {
        cleanupFunctionRef.current?.();
    }
}, [])

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

None

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.

@nkdengineer
Copy link
Contributor

@jnowakow What do you think about my proposal?

@ChavdaSachin
Copy link
Contributor

Solution from #59833 (comment) is almost good but doesn't work when navigating back using chevron:

That would be a simple fix on top of my proposal.
Instead of using useMoneyRequestReportContext we could directly use useState to hold selections like all other pages.
It would clear selections when page unmount.

I will update my proposal shortly and would upload a resulting video.

cc. @jnowakow

Copy link

melvin-bot bot commented Apr 9, 2025

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

Copy link

melvin-bot bot commented Apr 9, 2025

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@DylanDylann
Copy link
Contributor

@jnowakow You will solve this issue in somewhere, right?

@jnowakow
Copy link
Contributor

@ChavdaSachin your video shows search page instead of new report page.

@jnowakow
Copy link
Contributor

@DylanDylann there are several issues on this page and we're working on follow-ups so we will handle this. cc @mountiny

Copy link

melvin-bot bot commented Apr 17, 2025

@DylanDylann Still overdue 6 days?! Let's take care of this!

@melvin-bot melvin-bot bot added the Overdue label Apr 17, 2025
Copy link

melvin-bot bot commented Apr 21, 2025

@DylanDylann 10 days overdue. I'm getting more depressed than Marvin.

@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 21, 2025
@melvin-bot melvin-bot bot changed the title [Better Expense Report View] Checkbox state is not reset after switching tabs [Due for payment 2025-04-28] [Better Expense Report View] Checkbox state is not reset after switching tabs Apr 21, 2025
@melvin-bot melvin-bot bot removed the Overdue label Apr 21, 2025
Copy link

melvin-bot bot commented Apr 21, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.30-4 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-04-28. 🎊

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

  • @jnowakow does not require payment (Contractor)
  • @allgandalf requires payment (Needs manual offer from BZ)
  • @DylanDylann requires payment through NewDot Manual Requests

@allgandalf
Copy link
Contributor

Good to close, no checklist here!

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 28, 2025
Copy link

melvin-bot bot commented Apr 28, 2025

Issue is ready for payment but no BZ is assigned. @zanyrenney you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

Copy link

melvin-bot bot commented Apr 28, 2025

Payment Summary

Upwork Job

  • Contributor: @jnowakow is from an agency-contributor and not due payment
  • ROLE: @allgandalf paid $(AMOUNT) via Upwork (LINK)
  • Reviewer: @DylanDylann owed $250 via NewDot

BugZero Checklist (@zanyrenney)

  • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@zanyrenney
Copy link
Contributor

@allgandalf - how come no checklist is required here? Is no payment due?

@allgandalf
Copy link
Contributor

This issue is part of better expense report project, so regression tests will be added later and yes, no payment due here as we'll be paid separately at the end of project

@zanyrenney
Copy link
Contributor

Awesome, thanks for letting me know @allgandalf - closing this out given the comment above.

@github-project-automation github-project-automation bot moved this from Second Cohort - CRITICAL to Done in [#whatsnext] #migrate Apr 29, 2025
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 Daily KSv2 Engineering
Projects
Development

No branches or pull requests

10 participants