You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2025-08-01] [$250] mWeb - Expense - Create expense page is shown briefly when adding unreported expense to report #65472
Version Number: V9.1.76-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from TestRail:https://expensify.testrail.io/index.php?/tests/view/6428613 Email or phone of affected tester (no customers): Slottwo1 249553g44@gmail.com Issue reported by: Applause Internal Team Device used: Redminote 10s android 13 App Component: Money Requests
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.
changed the title [-]mWeb - Expense - Create expense page is shown briefly when adding unreported expense to report[/-][+][$250] mWeb - Expense - Create expense page is shown briefly when adding unreported expense to report[/+]on Jul 4, 2025
Please re-state the problem that we are trying to solve in this issue.
When adding unreported expenses to a report, users briefly see the "create expense" page (empty state) before the modal is dismissed.
What is the root cause of that problem?
The issue happens because when we call changeTransactionsReport(), the unreported expenses immediately become reported expenses. This makes thereIsNoUnreportedTransaction become true, which triggers the component to re-render and show the empty state with the "create expense" button. This re-render happens before the modal is fully dismissed, causing the brief flash.
The problem occurs in this sequence:
User clicks "Add to report"
changeTransactionsReport() runs and moves expenses to the report
thereIsNoUnreportedTransaction becomes true because no unreported expenses are left
Component re-renders and shows empty state
Modal dismisses, but user already saw the empty state flash
What changes do you think we should make in order to solve the problem?
We should add a state flag to track when we are in the process of adding transactions. This will prevent the empty state from showing during the transition period:
Add a new state isAddingTransactions to track when we're processing transactions
Now even when all unreported expenses are moved to reports, the empty state won't show during the transition because isAddingTransactions will be true.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
I don't think we need test for this, however if we want we can add a test to not show the EmptyStateComponent if the isAddingTransactions is true.
What alternative solutions did you explore? (Optional)
Using InteractionManager.runAfterInteractions(): This approach delays the changeTransactionsReport() call until after the modal dismisses. However, this creates another bug because:
The expenses appears in the next report screen with a delay
Video for main solutionScreen.Recording.2025-07-04.at.11.34.23.AM.mov
Because the change transaction will change optimistic data first, it will re-render the list with an empty list. And we will see EmptyStateComponent before the modal is dismissed.
What changes do you think we should make in order to solve the problem?
We should ensure that the data immediately before and after confirmation remains unchanged. This guarantees the list continues to render smoothly and prevents a delay where the new transaction is only added after the modal has fully disappeared
Create a new ref to capture the transactions value as soon as the user confirms.
function getUnreportedTransactions(transactions: OnyxCollection<Transaction>) {
+ if (transactionsAfterConfirmRef.current) {+ return transactionsAfterConfirmRef.current;+ }
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)
NA
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.
changed the title [-][$250] mWeb - Expense - Create expense page is shown briefly when adding unreported expense to report[/-][+][Due for payment 2025-08-01] [$250] mWeb - Expense - Create expense page is shown briefly when adding unreported expense to report[/+]on Jul 25, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.85-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@allroundexperts@kadiealexander 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]
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Activity
melvin-bot commentedon Jul 4, 2025
Triggered auto assignment to @kadiealexander (
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.daledah commentedon Jul 4, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
On adding unreported expense to report briefly create expense page is shown.
What is the root cause of that problem?
We call
dismissModalandchangeTransactionsReportat the same timeApp/src/pages/AddUnreportedExpense.tsx
Lines 184 to 185 in 755b505
So the optimistic data is merged before the screen finishes navigating and "No unreported expenses" is shown briefly
App/src/pages/AddUnreportedExpense.tsx
Lines 98 to 140 in 755b505
What changes do you think we should make in order to solve the problem?
We should delay the
changeTransactionsReporthereApp/src/pages/AddUnreportedExpense.tsx
Lines 184 to 185 in 755b505
Screen.Recording.2025-07-04.at.11.33.43.mov
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
None, UI issue.
What alternative solutions did you explore? (Optional)
We can call
changeTransactionsReporton page unmount, but this approach will make more delays. Implement like belowApp/src/pages/AddUnreportedExpense.tsx
Lines 179 to 187 in 755b505
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.
melvin-bot commentedon Jul 4, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021940997829224157860
[-]mWeb - Expense - Create expense page is shown briefly when adding unreported expense to report[/-][+][$250] mWeb - Expense - Create expense page is shown briefly when adding unreported expense to report[/+]melvin-bot commentedon Jul 4, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @allroundexperts (
External)Shahidullah-Muffakir commentedon Jul 4, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
When adding unreported expenses to a report, users briefly see the "create expense" page (empty state) before the modal is dismissed.
What is the root cause of that problem?
The issue happens because when we call
changeTransactionsReport(), the unreported expenses immediately become reported expenses. This makesthereIsNoUnreportedTransactionbecometrue, which triggers the component to re-render and show the empty state with the "create expense" button. This re-render happens before the modal is fully dismissed, causing the brief flash.The problem occurs in this sequence:
changeTransactionsReport()runs and moves expenses to the reportthereIsNoUnreportedTransactionbecomestruebecause no unreported expenses are leftWhat changes do you think we should make in order to solve the problem?
We should add a state flag to track when we are in the process of adding transactions. This will prevent the empty state from showing during the transition period:
isAddingTransactionsto track when we're processing transactionsthereIsNoUnreportedTransactioncondition to also check this flagApp/src/pages/AddUnreportedExpense.tsx
Line 77 in 755b505
as:
truebefore processing transactionsApp/src/pages/AddUnreportedExpense.tsx
Lines 179 to 187 in 755b505
as:
onConfirm={() => { if (selectedIds.size === 0) { setErrorMessage(translate('iou.selectUnreportedExpense')); return; } + setIsAddingTransactions(true); Navigation.dismissModal(); changeTransactionsReport([...selectedIds], report?.reportID ?? CONST.REPORT.UNREPORTED_REPORT_ID, policy); setErrorMessage(''); }}Now even when all unreported expenses are moved to reports, the empty state won't show during the transition because
isAddingTransactionswill betrue.What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
I don't think we need test for this, however if we want we can add a test to not show the
EmptyStateComponentif theisAddingTransactionsis true.What alternative solutions did you explore? (Optional)
Using InteractionManager.runAfterInteractions(): This approach delays the
changeTransactionsReport()call until after the modal dismisses. However, this creates another bug because:Video for main solution
Screen.Recording.2025-07-04.at.11.34.23.AM.mov
dmkt9 commentedon Jul 5, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Create expense page is shown briefly when adding unreported expense to report
What is the root cause of that problem?
App/src/pages/AddUnreportedExpense.tsx
Lines 184 to 185 in f181a83
EmptyStateComponentbefore the modal is dismissed.What changes do you think we should make in order to solve the problem?
We should ensure that the data immediately before and after confirmation remains unchanged. This guarantees the list continues to render smoothly and prevents a delay where the new transaction is only added after the modal has fully disappeared
App/src/pages/AddUnreportedExpense.tsx
Line 48 in f181a83
+ const transactionsAfterConfirmRef = useRef<Array<OnyxEntry<Transaction>> | null>(null); function getUnreportedTransactions(transactions: OnyxCollection<Transaction>) {App/src/pages/AddUnreportedExpense.tsx
Line 184 in f181a83
+ transactionsAfterConfirmRef.current = transactions; Navigation.dismissModal();App/src/pages/AddUnreportedExpense.tsx
Line 48 in f181a83
function getUnreportedTransactions(transactions: OnyxCollection<Transaction>) { + if (transactionsAfterConfirmRef.current) { + return transactionsAfterConfirmRef.current; + }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)
NA
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.
19 remaining items
[-][$250] mWeb - Expense - Create expense page is shown briefly when adding unreported expense to report[/-][+][Due for payment 2025-08-01] [$250] mWeb - Expense - Create expense page is shown briefly when adding unreported expense to report[/+]melvin-bot commentedon Jul 25, 2025
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jul 25, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.85-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 2025-08-01. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Jul 25, 2025
@allroundexperts @kadiealexander 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]
allroundexperts commentedon Jul 26, 2025
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] 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: https://github.com/Expensify/App/pull/62651/files#r2233257366
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/531776
Regression Test Proposal
Precondition:
Test:
Verify that on adding the unreported expense to a report, the create expense page does not show up briefly.
Do we agree 👍 or 👎
kadiealexander commentedon Aug 1, 2025
Payments needed:
trjExpensify commentedon Jan 5, 2026
approved $250 for @allroundexperts.