Skip to content

[Due for payment 2025-11-04] [$250] Report - When moving several expenses to new report offline, amount on preview shows "0,00" #72743

Closed

Description

@jponikarchuk

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: 9.2.32-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-1308/folder/13176670/41237099/955761115
Email or phone of affected tester (no customers): ibellicotest+1926@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 / Android 12 / Chrome ( mWeb / Hybrid app) - Windows 11 / Chrome
App Component: Money Requests

Action Performed:

Prerequisite: Account has at least one workspace.

  1. Open the Expensify app.
  2. Open any workspace chat.
  3. Create at least two manual expenses.
  4. Turn off internet connection.
  5. Open the report of the just created expenses.
  6. Long tap and select all the expenses.
  7. Tap on the dropdown menu and select "Move Expenses"
  8. Tap on "Create Report"
  9. Once the expenses were moved, return to chat.
  10. Note that total amount on preview of new created report, shows "0,00"
  11. Open the report.
  12. Note that total amount, also shows "0,00" inside report.
  13. Return to chat and turn on internet connection again.
  14. Note that total amount is now updated.

Expected Result:

When moving more than one expense to a new report while offline, total amount field displayed on new report preview, should display the correct expenses amount.

Actual Result:

When moving more than one expense to a new report while in offline mode, preview of new report shows "0,00" as total amount. When opening report, total amount inside report is also "0,00".
Total amount fields update after recovering internet connection.

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

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021980306924002190932
  • Upwork Job ID: 1980306924002190932
  • Last Price Increase: 2025-10-20
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @trjExpensify

Activity

  1. added
    Daily
    Bug
    on Oct 16, 2025
  2. melvin-bot commented on Oct 16, 2025

    @melvin-bot

    Triggered auto assignment to @trjExpensify (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. ShridharGoel commented on Oct 16, 2025

    @ShridharGoel
    Contributor

    Proposal

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

    Moving multiple expenses into a brand-new report while offline shows the new report total as 0.00 on the chat preview and inside the report itself. The total only updates after the device reconnects, which confuses the user about whether the move succeeded.

    What is the root cause of that problem?

    The optimistic move logic only subtracts amounts from the newReport object that exists in Onyx. When the report is freshly created offline, that entry is not yet stored, so we subtract from undefined, end up with zero totals, and pass the wrong report data into the next-step builder. The implementation can be seen in changeTransactionsReport, where totals for the destination report were read exclusively from newReport:

    if (reportID && newReport) {
    updatedReportTotals[targetReportID] = (updatedReportTotals[targetReportID] ? updatedReportTotals[targetReportID] : (newReport.total ?? 0)) - transactionAmount;
    updatedReportNonReimbursableTotals[targetReportID] =
    (updatedReportNonReimbursableTotals[targetReportID] ? updatedReportNonReimbursableTotals[targetReportID] : (newReport.nonReimbursableTotal ?? 0)) -
    (transactionReimbursable ? 0 : transactionAmount);
    updatedReportUnheldNonReimbursableTotals[targetReportID] =
    (updatedReportUnheldNonReimbursableTotals[targetReportID] ? updatedReportUnheldNonReimbursableTotals[targetReportID] : (newReport.unheldNonReimbursableTotal ?? 0)) -
    (transactionReimbursable && !isOnHold(transaction) ? 0 : transactionAmount);
    }

    and nextStepReport was constructed from the same incomplete source:

    const nextStepReport = {...newReport, total: updatedReportTotals[reportID] ?? newReport?.total, reportID: newReport?.reportID ?? reportID};
    const hasViolations = hasViolationsReportUtils(nextStepReport?.reportID, allTransactionViolation);
    const optimisticNextStep = buildNextStepNew({
    report: nextStepReport,
    policy,
    currentUserAccountIDParam: accountID,
    currentUserEmailParam: email,
    hasViolations,
    isASAPSubmitBetaEnabled,
    predictedNextStatus: nextStepReport.statusNum ?? CONST.REPORT.STATUS_NUM.OPEN,
    shouldFixViolations,
    });
    optimisticData.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${reportID}`,
    value: optimisticNextStep,
    });

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

    1. When we update optimistic totals, resolve the destination report from any available source (existing Onyx data, the optimistic newReport, or the freshly created self-DM) and reuse whatever current totals are present before subtracting the moved amounts.
    2. Build the next-step payload from that same resolved report object so we keep totals and metadata consistent.

    Updated logic for computing report totals and next-step data:

    const allowNegative = shouldEnableNegative(newReport, policy);
    ...
    if (targetReportID) {
        const targetReportKey = `${ONYXKEYS.COLLECTION.REPORT}${targetReportID}`;
        const targetReport =
            allReports?.[targetReportKey] ??
            (targetReportID === newReport?.reportID ? newReport : undefined) ??
            (targetReportID === selfDMReport?.reportID ? selfDMReport : undefined);
    
        const currentTotal = updatedReportTotals[targetReportID] ?? (targetReport?.total ?? 0);
        updatedReportTotals[targetReportID] = currentTotal - transactionAmount;
    
        const currentNonReimbursableTotal = updatedReportNonReimbursableTotals[targetReportID] ?? (targetReport?.nonReimbursableTotal ?? 0);
        updatedReportNonReimbursableTotals[targetReportID] = currentNonReimbursableTotal - (transactionReimbursable ? 0 : transactionAmount);
    
        const currentUnheldNonReimbursableTotal = updatedReportUnheldNonReimbursableTotals[targetReportID] ?? (targetReport?.unheldNonReimbursableTotal ?? 0);
        updatedReportUnheldNonReimbursableTotals[targetReportID] = currentUnheldNonReimbursableTotal - (transactionReimbursable && !isOnHold(transaction) ? 0 : transactionAmount);
    }
    ...
    const destinationReportID = reportID === CONST.REPORT.UNREPORTED_REPORT_ID ? existingSelfDMReportID ?? selfDMReport?.reportID : reportID;
    const destinationReport =
        destinationReportID
            ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${destinationReportID}`] ??
              (destinationReportID === newReport?.reportID ? newReport : undefined) ??
              (destinationReportID === selfDMReport?.reportID ? selfDMReport : undefined)
            : undefined;
    const destinationTotal = (destinationReportID ? updatedReportTotals[destinationReportID] : undefined) ?? destinationReport?.total ?? newReport?.total;
    const nextStepReport = {
        ...destinationReport,
        reportID: destinationReport?.reportID ?? destinationReportID ?? reportID,
        total: destinationTotal,
    };
  4. mkzie2 commented on Oct 16, 2025

    @mkzie2
    Contributor

    Proposal

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

    When moving more than one expense to a new report while in offline mode, preview of new report shows "0,00" as total amount. When opening report, total amount inside report is also "0,00".
    Total amount fields update after recovering internet connection.

    What is the root cause of that problem?

    We are not update the UI if options of list are equal based on shallowOptionsListCompare

    const areOptionsEqual = shallowOptionsListCompare(prevOptions.current, optionsList);
    prevOptions.current = optionsList;
    if (areOptionsEqual) {
    return;
    }

    However, in shallowOptionsListCompare, we only compare length, reportId, and login

    if (a.reports.length !== b.reports.length || a.personalDetails.length !== b.personalDetails.length) {
    return false;
    }
    for (let i = 0; i < a.reports.length; i++) {
    if (a.reports.at(i)?.reportID !== b.reports.at(i)?.reportID) {
    return false;
    }
    }
    for (let i = 0; i < a.personalDetails.length; i++) {
    if (a.personalDetails.at(i)?.login !== b.personalDetails.at(i)?.login) {
    return false;
    }
    }

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

    We should add logic to compare text or amount values as well here

    What alternative solutions did you explore? (Optional)

    We can use deep compare

    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.

  5. paulnjs commented on Oct 16, 2025

    @paulnjs
    Contributor

    Proposal

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

    When moving more than one expense to a new report while in offline mode, preview of new report shows "0,00" as total amount. When opening report, total amount inside report is also "0,00".
    Total amount fields update after recovering internet connection.

    What is the root cause of that problem?

    Select Create report option will create an optimistic report

    const createdReportID = createNewReport(currentUserPersonalDetails, hasViolations, isASAPSubmitBetaEnabled, policyForMovingExpensesID);

    But it's not updated with the value from Onyx.connect here at the time we call changeTransactionsReport

    const newReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];

    Which causes the total isn't updated here because newReport is undefined

    if (oldReport) {
    updatedReportTotals[oldReportID] = (updatedReportTotals[oldReportID] ? updatedReportTotals[oldReportID] : (oldReport?.total ?? 0)) + transactionAmount;
    updatedReportNonReimbursableTotals[oldReportID] =
    (updatedReportNonReimbursableTotals[oldReportID] ? updatedReportNonReimbursableTotals[oldReportID] : (oldReport?.nonReimbursableTotal ?? 0)) +
    (transaction?.reimbursable ? 0 : transactionAmount);
    updatedReportUnheldNonReimbursableTotals[oldReportID] =
    (updatedReportUnheldNonReimbursableTotals[oldReportID] ? updatedReportUnheldNonReimbursableTotals[oldReportID] : (oldReport?.unheldNonReimbursableTotal ?? 0)) +
    (transaction?.reimbursable && !isOnHold(transaction) ? 0 : transactionAmount);
    }
    if (reportID && newReport) {
    updatedReportTotals[targetReportID] = (updatedReportTotals[targetReportID] ? updatedReportTotals[targetReportID] : (newReport.total ?? 0)) - transactionAmount;
    updatedReportNonReimbursableTotals[targetReportID] =
    (updatedReportNonReimbursableTotals[targetReportID] ? updatedReportNonReimbursableTotals[targetReportID] : (newReport.nonReimbursableTotal ?? 0)) -
    (transactionReimbursable ? 0 : transactionAmount);

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

    We should pass newReport to changeTransactionsReport function here

    1. Define a new param
    function changeTransactionsReport(
        transactionIDs: string[],
        reportID: string,
        isASAPSubmitBetaEnabled: boolean,
        accountID: number,
        email: string,
        policy?: OnyxEntry<Policy>,
        reportNextStep?: OnyxEntry<ReportNextStep>,
        policyCategories?: OnyxEntry<PolicyCategories>,
        newReportParam?: OnyxEntry<Report>,
    ) {
        const newReport = newReportParam ?? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
    
    1. Return optimisticReport value in createNewReport
    return {
            ...
            optimisticReport: optimisticReportData,
        };
    

    return {

    const {optimisticReportName, parentReportID, reportPreviewAction, optimisticData, successData, failureData, optimisticReport} = buildNewReportOptimisticData(
    return optimisticReport;
    

    return optimisticReportID;

    1. Move create report logic to selectReport and pass the optimistic report to changeTransactionsReport
    const selectReport = (item: TransactionGroupListItem, shouldCreateNewReport = false) => {
        ...
    
        let newReport: OptimisticNewReport | undefined;
        let newReportID = item.value;
        if (shouldCreateNewReport) {
            const createdReport = createNewReport(currentUserPersonalDetails, hasViolations, isASAPSubmitBetaEnabled, policyForMovingExpensesID);
            newReport = createdReport;
            newReportID = createdReport.reportID;
        }
    
        changeTransactionsReport(
            ...
            newReport,
        );
        turnOffMobileSelectionMode();
        clearSelectedTransactions(true);
        Navigation.dismissModal();
    };
    
    const createReport = () => {
            ...
            selectReport({value: ''}, true);
        };
    

    Optional: To avoid two APIs are called in this case, we can move the logic create new report to changeTransactionsReport as optimistic data and we need to define new parameter for this API to create new expense report, new report preview action, ...

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

    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.

  6. trjExpensify commented on Oct 20, 2025

    @trjExpensify
    Contributor

    @cristipaval @luacmartins I'd appreciate your eyes on this. I tried to compare with the Create report flow and the report total in the preview is accurately updated optimistically.

    2025-10-20_12-04-09.mp4
  7. luacmartins commented on Oct 20, 2025

    @luacmartins
    Contributor

    Seems like an edge case when merging the optimistic update. I think we already have a few proposals that hint on the RCA. Gonna make this external.

  8. self-assigned this
    on Oct 20, 2025
  9. added
    External
    on Oct 20, 2025
  10. changed the title [-]Report - When moving several expenses to new report offline, amount on preview shows "0,00"[/-] [+][$250] Report - When moving several expenses to new report offline, amount on preview shows "0,00"[/+] on Oct 20, 2025
  11. melvin-bot commented on Oct 20, 2025

    @melvin-bot
  12. 16 remaining items

  13. added
    Weekly
    Awaiting Payment
    and removed
    Weekly
    on Oct 25, 2025
  14. changed the title [-][$250] Report - When moving several expenses to new report offline, amount on preview shows "0,00"[/-] [+][Due for payment 2025-11-04] [$250] Report - When moving several expenses to new report offline, amount on preview shows "0,00"[/+] on Oct 28, 2025
  15. melvin-bot commented on Oct 28, 2025

    @melvin-bot

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

  16. removed
    Reviewing
    on Oct 28, 2025
  17. melvin-bot commented on Oct 28, 2025

    @melvin-bot

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

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

    • @ShridharGoel requires payment through NewDot Manual Requests
    • @ikevin127 requires payment through NewDot Manual Requests
  18. melvin-bot commented on Oct 28, 2025

    @melvin-bot

    @ikevin127 @trjExpensify 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]

  19. ikevin127 commented on Nov 4, 2025

    @ikevin127
    Contributor

    BugZero Checklist:

    • [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: N/A - Mistake during implementation

    • [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:

    Regression Test Proposal

    Prerequisite: Account has at least one workspace.

    1. Open the Expensify app.
    2. Open any workspace chat.
    3. Create at least two manual expenses.
    4. Turn off internet connection.
    5. Open the report of the just created expenses.
    6. Long tap and select all the expenses.
    7. Tap on the dropdown menu and select "Move Expenses".
    8. Tap on "Create Report".
    9. Once the expenses were moved, return to chat.
    10. Note that total amount on preview of new created report shows the correct amount.
    11. Open the report.
    12. Verify that the total amount, also shows shows the correct amount inside the report.
    13. Return to chat and turn the internet connection back on.
    14. Verify that the total amount remains the same as when offline.

    Do we agree 👍 or 👎.

  20. trjExpensify commented on Nov 4, 2025

    @trjExpensify
    Contributor

    Thanks!

    Payment summary as follows:

    Both of you can go ahead and request. Closing!

  21. garrettmknight commented on Nov 7, 2025

    @garrettmknight
    Contributor

    $250 approved for @ikevin127

  22. garrettmknight commented on Nov 11, 2025

    @garrettmknight
    Contributor

    $250 approved for @ShridharGoel

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

Metadata

Metadata

Labels

Awaiting PaymentBugExternalWeekly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions