Skip to content

[Due for payment 2026-02-27] [$250] Invoice - Invoice amount on receiver side in Pay option selected via checkbox in Reports page does not display the amount changed by sender #79417

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.3.0-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: Exploratory around https://test-management.browserstack.com/projects/2219752/test-runs/TR-2922/folder/13176671/41237464/1121355055 & https://test-management.browserstack.com/projects/2219752/test-runs/TR-2922/folder/13176671/41237470/1121355058 & https://test-management.browserstack.com/projects/2219752/test-runs/TR-2922/folder/13176671/41237471/1121355059
Email or phone of affected tester (no customers): kiatest.80+ck1122650@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Windows 11/Chrome, iPhone 16/iOS 18.7.1
App Component: Money Requests

Action Performed:

Precondition:

  1. Invoices enabled in workspace
  2. Invoice sender has invited receiver to workspace
    Steps:
    Perform below steps on Sender's side:
  3. Navigate to staging.new.expensify.com
  4. Tap FAB >> Invoices >> Go through the flow & send an invoice to receiver
  5. Navigate to invoice details & change the invoice amount

Perform below steps on Receiver's side

  1. Navigate to staging.new.expensify.com
  2. Go To Reports menu >> Invoice type
  3. Select the invoice via checkbox
  4. Select Pay option
  5. Observe wrong invoice amount (does not show the edited amount done by sender) is displayed in Pay as individual & business option

Expected Result:

Invoice amount on receiver's side in Pay as individual & business option selected via checkbox in Reports page should display the correct edited amount changed by sender

Actual Result:

Invoice amount on receiver's side in Pay as individual & business option in Reports page does not display the correct edited amount changed by sender
Pay button dropdown show correct changed amount while the Pay option via checkbox still display the original amount done while creating invoice but not the edited amount

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022011218062525274970
  • Upwork Job ID: 2011218062525274970
  • Last Price Increase: 2026-02-04
Issue OwnerCurrent Issue Owner: @brianlee-expensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jan 13, 2026
  2. melvin-bot commented on Jan 13, 2026

    @melvin-bot

    Triggered auto assignment to @brianlee-expensify (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. daledah commented on Jan 13, 2026

    @daledah
    Contributor

    Proposal

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

    When a sender edits an invoice amount after sending it, the receiver sees the wrong (original) amount when selecting the invoice via checkbox in the Reports page and clicking the Pay option. The Pay button dropdown shows the correct edited amount, but the bulk Pay option via checkbox still displays the original amount.

    What is the root cause of that problem?

    The root cause is in src/components/Search/SearchContext.tsx. When invoices are selected via checkbox, the total value is captured from the search snapshot data and stored in selectedReports at the time of selection:

    if (data.length && data.every(isTransactionReportGroupListItemType)) {
    selectedReports = data
    .filter((item) => isMoneyRequestReport(item) && item.transactions.length > 0 && item.transactions.every(({keyForList}) => selectedTransactions[keyForList]?.isSelected))
    .map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, total = CONST.DEFAULT_NUMBER_ID, policyID, allActions = [action], currency, chatReportID}) => ({
    reportID,
    action,
    total,
    policyID,
    allActions,
    currency,
    chatReportID,
    }));

    } else if (data.length && data.every(isTransactionListItemType)) {
    selectedReports = data
    .filter(({keyForList}) => !!keyForList && selectedTransactions[keyForList]?.isSelected)
    .map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, amount: total = CONST.DEFAULT_NUMBER_ID, policyID, allActions = [action], currency, report}) => ({
    reportID,
    action,
    total,
    policyID,
    allActions,
    currency,
    chatReportID: report?.chatReportID,
    }));
    }

    This cached total is then used by:

    App/src/libs/actions/Search.ts

    Lines 1203 to 1211 in 98a3245

    function getTotalFormattedAmount(selectedReports: SelectedReports[], selectedTransactions: SelectedTransactions, currency?: string): string {
    const transactionKeys = Object.keys(selectedTransactions ?? {});
    const totalAmount =
    selectedReports.length > 0
    ? selectedReports.reduce((acc, report) => acc + (Math.abs(report.total) ?? 0), 0)
    : transactionKeys.reduce((acc, transactionIdKey) => acc + (Math.abs(selectedTransactions[transactionIdKey].amount) ?? 0), 0);
    const formattedAmount = convertToDisplayString(totalAmount, currency);
    return formattedAmount ?? '';
    }

    amount: report.total,

    When the sender edits the invoice amount, the search snapshot data in selectedReports is not automatically refreshed with the new total from Onyx, causing the stale amount to be displayed.

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

    We should fetch the latest report total from live Onyx data instead of using the cached total from selectedReports. Specifically:

    1. In SearchPage.tsx, when building paymentData for onBulkPaySelected, use the current report total from Onyx (currentSearchResults?.data?.[ONYXKEYS.COLLECTION.REPORT${reportID}]?.total) instead of report.total from selectedReports.
        const totalFormattedAmount = getTotalFormattedAmount(selectedReports, selectedTransactions, selectedBulkCurrency, allReports);
    
    1. Similarly, update getTotalFormattedAmount to accept the current search results and fetch the latest total from Onyx for each selected report.
                    selectedReports.reduce((acc, report) => {
                      // Fetch the latest total from Onyx if allReports is provided, otherwise use cached total
                      const latestTotal = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]?.total ?? report.total;
                      return acc + (Math.abs(latestTotal) ?? 0);
                  }, 0)
    

    App/src/libs/actions/Search.ts

    Lines 1205 to 1208 in 98a3245

    const totalAmount =
    selectedReports.length > 0
    ? selectedReports.reduce((acc, report) => acc + (Math.abs(report.total) ?? 0), 0)
    : transactionKeys.reduce((acc, transactionIdKey) => acc + (Math.abs(selectedTransactions[transactionIdKey].amount) ?? 0), 0);

    What alternative solutions did you explore? (Optional)

    An alternative would be to invalidate/refresh selectedReports whenever report data changes in Onyx. However, this approach would add unnecessary complexity and performance overhead by requiring subscriptions to report changes. Fetching the latest data at payment time is simpler and more reliable.

  4. annaweber830 commented on Jan 13, 2026

    @annaweber830
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-01-16 20:31:55 UTC.

    Proposal

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

    Invoice amount on receiver's side in Pay as individual & business option selected via checkbox in Reports page should display the correct edited amount changed by sender

    What is the root cause of that problem?

    The checkbox bulk-pay flow relies on selectedReports data captured at selection time from the search list item snapshot, including a total field. When the invoice is later edited, the authoritative report total is updated in Onyx, but the already-stored selectedReports[].total is not refreshed, so the bulk Pay UI/logic continues using a stale total.

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

    Use the cached snapshot total only as a fallback, but derive the amount for bulk invoice Pay from the latest report data when available:

    • When rendering the bulk Pay submenu (e.g., “Pay as individual/business”), compute the displayed total using the current report total for the selected reportIDs (live report data), falling back to the cached snapshot total if the live report is not available.
    • When constructing the bulk payment payload (the paymentData sent to payMoneyRequestOnSearch), use the latest report total for each selected invoice report, again with a fallback to the cached snapshot total.
      Keep the selection model (selectedReports) as-is to avoid extra subscriptions/complexity; just re-resolve totals at “Pay” time.
      This aligns the checkbox Pay flow with the already-correct behavior seen in the Pay button dropdown (which is based on live report data) and fixes the stale amount after edits.
      We should add this code to SearchPage

    const isCurrencySupportedBulkWallet = isCurrencySupportWalletBulkPay(selectedReports, selectedTransactions);

        const selectedReportsWithLatestSnapshotTotals = useMemo(
            () =>
                selectedReports.map((selectedReport) => {
                    const reportID = selectedReport.reportID;
                    if (!reportID) {
                        return selectedReport;
                    }
    
                    const latestSnapshotReport = currentSearchResults?.data?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`] as Report | undefined;
    
                    return {
                        ...selectedReport,
                        total: latestSnapshotReport?.total ?? selectedReport.total,
                        currency: latestSnapshotReport?.currency ?? selectedReport.currency,
                        chatReportID: latestSnapshotReport?.chatReportID ?? selectedReport.chatReportID,
                    };
                }),
            [currentSearchResults?.data, selectedReports],
        );
    
        const isCurrencySupportedBulkWallet = isCurrencySupportWalletBulkPay(selectedReportsWithLatestSnapshotTotals, selectedTransactions);
        
    

    const selectedBulkCurrency = selectedReports.at(0)?.currency ?? Object.values(selectedTransactions).at(0)?.currency;
    const totalFormattedAmount = getTotalFormattedAmount(selectedReports, selectedTransactions, selectedBulkCurrency);

     const selectedBulkCurrency = selectedReportsWithLatestSnapshotTotals.at(0)?.currency ?? Object.values(selectedTransactions).at(0)?.currency;
        const totalFormattedAmount = getTotalFormattedAmount(selectedReportsWithLatestSnapshotTotals, selectedTransactions, selectedBulkCurrency);
    
    

    const selectedOptions = selectedReports.length ? selectedReports : Object.values(selectedTransactions);

    const selectedOptions = selectedReports.length ? selectedReportsWithLatestSnapshotTotals : Object.values(selectedTransactions);

    selectedReports.length
    ? selectedReports.map((report) => {
    return {

    selectedReports.length
                        ? selectedReportsWithLatestSnapshotTotals.map((report) => {
                              return {
                    
    

    What alternative solutions did you explore? (Optional)

    We can apply the same “use latest report total” approach to any other pay paths that use snapshot totals for invoices, to avoid similar drift outside the checkbox flow.

  5. changed the title [-]Invoice - Invoice amount on receiver side in Pay option selected via checkbox in Reports page does not display the amount changed by sender[/-] [+][$250] Invoice - Invoice amount on receiver side in Pay option selected via checkbox in Reports page does not display the amount changed by sender[/+] on Jan 13, 2026
  6. melvin-bot commented on Jan 13, 2026

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 13, 2026
  8. melvin-bot commented on Jan 13, 2026

    @melvin-bot

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

  9. ahmedGaber93 commented on Jan 16, 2026

    @ahmedGaber93
    Contributor

    Thanks everyone for the proposals.

    I don’t think using total from Onyx data is a good approach. In some cases, the Onyx data isn’t available before the report is opened. I think we should rely on the snapshot data instead, if possible.

    A couple of clarifying questions:

    • Does the snapshot data include the modified amount? If so, why can’t we use it? If not, can we ask the backend to include it?
    • How do expense reports currently handle modified amounts? Can we align this behavior here?
  10. annaweber830 commented on Jan 16, 2026

    @annaweber830
    Contributor

    Hi @ahmedGaber93

    • Does the snapshot data include the modified amount?
      Yes, but only after it’s refreshed. The Search “snapshot” (ONYXKEYS.COLLECTION.SNAPSHOT...) is essentially the cached result of the last Search API response. If the sender edits the invoice after the receiver last fetched Search, the receiver’s snapshot can still contain the old report.total. That’s why “just use snapshot” (especially the cached selectedReports.total captured at checkbox time) can still show the wrong amount.
    • If so, why can’t we use it? If not, can we ask the backend to include it?
      We can use snapshot if we avoid caching and/or ensure the snapshot is updated. The core issue is staleness, not that the backend can’t represent the edited value. Asking the backend to “include it” doesn’t help unless we also ensure the receiver’s Search snapshot is refreshed at the right time (e.g., re-run Search when opening the bulk Pay menu, or update the snapshot when an invoice update arrives).
    • How do expense reports handle modified amounts? Can we align?
      Expenses track edits at the transaction level (e.g., modifiedAmount, modifiedCurrency, etc.), and UI generally reflects updates via live model data rather than a one-time cached total. Aligning here would mean: don’t rely on a cached total captured at selection time; instead re-resolve the amount at render/pay time from the best available source (snapshot if it’s current, otherwise a refreshed snapshot / live data).
  11. melvin-bot commented on Jan 20, 2026

    @melvin-bot

    @ahmedGaber93 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  12. 42 remaining items

  13. brianlee-expensify commented on Feb 28, 2026

    @brianlee-expensify
    Contributor

    @ahmedGaber93 bump for the above

  14. marufsharifi commented on Feb 28, 2026

    @marufsharifi

    @brianlee-expensify, please process the payment. I've accepted the offer. thanks.

  15. ahmedGaber93 commented on Feb 28, 2026

    @ahmedGaber93
    Contributor

    BugZero Checklist:

    Regression Test Proposal

    Precondition:

    • Workspace with Invoices enabled.
    • Invoice sender has invited the receiver to the workspace
    • It's the payer's first payment.

    Test:

    Perform the following steps on the sender's side:

    1. Tap FAB >> Invoices >> Go through the flow & send an invoice to receiver
    2. Navigate to invoice details & change the invoice amount

    Perform the following steps on the receiver's side

    1. Go to Reports >> Explore menu >> Reports
    2. Select Invoice type
    3. Select the invoice via the checkbox
    4. Select Pay option
    5. Verify that the correct invoice amount is displayed in the Pay as individual & business option

    Do we agree 👍 or 👎

  16. ahmedGaber93 commented on Feb 28, 2026

    @ahmedGaber93
    Contributor

    @brianlee-expensify checklist have been completed.

  17. marufsharifi commented on Mar 2, 2026

    @marufsharifi

    @brianlee-expensify, kindly bump. thanks.

  18. brianlee-expensify commented on Mar 2, 2026

    @brianlee-expensify
    Contributor

    Payment Summary

  19. JmillsExpensify commented on Mar 19, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @ahmedGaber93

  20. marufsharifi commented on Mar 26, 2026

    @marufsharifi

    @brianlee-expensify, thanks for the payment. Could you please end the Upwork contract? thanks.

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions