App icon indicating copy to clipboard operation
App copied to clipboard

[$175] Duplicate error "new expenses cannot be added to this report" is displayed

Open applause-bot[bot] opened this issue 6 days ago • 14 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.54-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://github.com/Expensify/App/pull/107654 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: windows 10/chrome App Component: Other

Action Performed:

Precondition: Create a workspace with Account A as a member and Account B as the approver

Steps:

  1. As Account A, create a manual expense and a scanned receipt expense on an open workspace report
  2. As Account A submit the expense report to Account B.
  3. As Account A, go to Account > Troubleshoot and turn Force offline on.
  4. As Account B, open and approve the submitted expense report.
  5. As Account A (still offline), open that same report and add a manual expense and a scanned receipt expense to it.
  6. As Account A, turn Force offline off.
  7. Verify error messages are displayed

Expected Result:

There should be no duplicate error messages, but only one error message under failed expense

Actual Result:

There is a duplicate error message "new expenses cannot be added to this report" in report page

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [x] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/7b09bd76-3611-404c-b51b-88482a978cdf

View all open jobs on GitHub

Applause Internal Information Exported by: Mita Rachim Bug ID: 7324553

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @ShridharGoel

applause-bot[bot] avatar Nov 26 '26 07:11 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/1b5b29958b09d0015731fb47402c82e321b01965b41427610a28aa4580f597bd

applause-bot[bot] avatar Nov 26 '26 07:11 applause-bot[bot]

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

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

Proposal

What is the root cause of that problem?

Likely cause — medium confidence: The expense report table has two independent places that display the same expense’s rejection: the transaction row’s error indicator and a separate error row underneath it. Deduplicating stored error strings does not prevent both components from displaying the same message.

Code evidence

This explains how one failed expense can display its rejection twice without duplicate requests or duplicate stored strings.

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

Give each rejection a single display owner within the report table. Coordinate the transaction-row indicator with the separate error row so an already-displayed rejection is not repeated.

Preserve distinct violations, error dismissal, and scanned-receipt Try again/Save behavior. Do not deduplicate across expenses: two failed expenses should each retain their own error.

Verification and regression coverage

Web reproduction was blocked, not failed: the tester could not operate a second account to approve the report while the first remained offline. Therefore, attribution to this particular report remains unconfirmed.

Before implementing, confirm that both messages belong to the same expense, rather than one message belonging to each failed expense.

Regression coverage should render the complete report-table item and verify:

  • One rejection per manual or scanned expense.
  • Two expenses with identical rejection text retain independent feedback.
  • Receipt recovery, dismissal, and unrelated violations remain available.
  • Both wide and narrow layouts behave correctly.

What alternative solutions did you explore? (Optional)

Changing client/server error reconciliation alone would not address two components displaying the same error. Globally hiding transaction-row errors would risk suppressing unrelated validation feedback.


Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/108054) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.


view run

MelvinBot avatar Nov 26 '26 07:11 MelvinBot

Proposal

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

After a manual and a scanned expense added offline to an already-approved report fail on reconnect, the report page shows the server rejection "new expenses cannot be added to this report" twice under the same failed expense instead of once.

What is the root cause of that problem?

Since #107654, the server's rejection string is kept in transaction.errors for the failed expense. The server's onyxData writes {<serverKey>: "new expenses cannot be added…"} on transactions_<id>, and reconcileFailureDataWithServerErrors drops the client's generic string. For the scan, it copies the same text into the ReceiptError.message. So each failed row ends up with exactly one string error, the server one.

In the report table, two separate components render that same string for the same row:

  1. MoneyRequestReportTransactionItem builds messageErrors from the string entries of transaction.errors and renders them in its own <ErrorMessageRow errors={transactionErrors}> (with the dismiss X).
  2. The <TransactionItemRow> it renders just above that row keeps the default shouldShowErrors = true, so the wide and narrow rows mount TransactionItemRowRBR. That component calls getRBRMessages, which runs extractErrorMessages(transaction.errors, …) and adds the same string again. For the scan, it also adds the ReceiptError.message, which since #107654 is the same text, so the Set collapses it to one.

The Set inside extractErrorMessages only removes duplicates within the RBR. Nothing removes duplicates between the RBR and the ErrorMessageRow, so each failed expense shows the message twice (once in the RBR and once in the dismissable error row). Before #107654, the client's generic failure was a translation-key object that messageErrors filters out. The ErrorMessageRow usually stayed empty for these failures, which is why this only shows up now.

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

Let the dismissable ErrorMessageRow be the only place that shows transaction.errors strings in the report table, and keep the RBR for everything else:

  1. Add an optional prop to TransactionItemRow → DeferredTransactionItemRowRBR → TransactionItemRowRBR, e.g. shouldExcludeTransactionStringErrors (default false, so Search and other users of the row don't change).
  2. When it's true, TransactionItemRowRBR passes transaction.errors to getRBRMessages without its plain string entries, the same filter MoneyRequestReportTransactionItem already uses for messageErrors. Receipt errors without a server message, transaction-thread action errors, violations and missingFieldError still show in the RBR as they do today. The early-return check in TransactionItemRowRBR should use the same filtered errors so it doesn't mount an empty RBR.
  3. MoneyRequestReportTransactionItem passes shouldExcludeTransactionStringErrors to TransactionItemRow, because it already renders those strings in its ErrorMessageRow.
  4. In the same filter, drop a ReceiptError whose message equals a string that ErrorMessageRow already shows. Then the scanned expense also shows the rejection only once, and its retry and save stay in the expense view.

Result: each failed expense (manual or scanned) shows the rejection exactly once, under the row, and the user can still dismiss it. Two failed expenses still each show their own message, and violations stay visible.

What alternative solutions did you explore? (Optional)

  • Pass shouldShowErrors={false} to TransactionItemRow from the report table. Rejected: it also hides violations and missing-field errors.
  • Remove the ErrorMessageRow and rely on the RBR. Rejected: that loses the dismiss action (clearError) for failed expenses.

How this differs from MelvinBot's proposal: Melvin points at the same two renderers but leaves the fix open ("coordinate … a single display owner") and could not confirm the scenario. This proposal traces the exact data flow from #107654 (why it's the same string, and why it only shows up now) and gives a concrete fix that only applies to the report table. That fix keeps violations, dismissal and per-expense errors, and it doesn't change Search rows.


Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01be5d412b545fdf18

akzkid avatar Nov 26 '26 07:11 akzkid

Proposal

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

When expenses added offline to an already-approved workspace report fail upon reconnecting (returning server rejection "new expenses cannot be added to this report"), the report page displays the rejection message twice under the same failed transaction row: once inside the Red Bullet Row (RBR) indicator and once directly beneath in the dismissible error container (ErrorMessageRow).

What is the root cause of that problem?

Recent PR #107654 (reconcileFailureDataWithServerErrors.ts) updated server error handling to preserve the server's rejection string directly in transaction.errors (e.g. {[timestamp]: "new expenses cannot be added to this report"}), and for scanned receipts, also into ReceiptError.message. Prior to PR #107654, client generic failure data used translation-key objects that were filtered out from messageErrors, so ErrorMessageRow did not mount for these errors.

With the raw string now stored in transaction.errors:

  1. In MoneyRequestReportTransactionItem.tsx:183-195, messageErrors extracts string entries from transaction.errors and passes them to <ErrorMessageRow errors={transactionErrors} onDismiss={dismissTransactionError} /> (rendered directly beneath <TransactionItemRow>). This component renders the dismissible error banner with an [X] dismiss button.
  2. In <TransactionItemRow> (rendered directly above), TransactionItemRowWide.tsx:815-826 and TransactionItemRowNarrow.tsx:196-207 mount <DeferredTransactionItemRowRBR> / <TransactionItemRowRBR>.
  3. In TransactionItemRowRBRInner, ViolationsUtils.getRBRMessages calls extractErrorMessages(transaction?.errors ?? {}, ...) (ViolationsUtils.ts:509-543), which extracts the same string from transaction.errors (and the matching ReceiptError.message) and renders ● new expenses cannot be added to this report. as a red bullet item within the transaction row.

Because extractErrorMessages only deduplicates within the RBR itself, and there was no coordination between TransactionItemRowRBR and the report view's external ErrorMessageRow, both UI components render the exact same error message under the same expense.

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

On the Money Request Report view (MoneyRequestReportTransactionItem), ErrorMessageRow is the designated container for transaction-level message errors because it provides the user with an actionable dismiss button (clearError). Therefore, transaction-level message errors that are already handled by ErrorMessageRow should be excluded from the row's RBR, while retaining all policy violations, missing field errors, and thread errors in the RBR:

  1. In src/components/TransactionItemRow/types.ts: Add an optional prop shouldExcludeTransactionErrors?: boolean to TransactionItemRowProps.

  2. In src/components/TransactionItemRow/index.tsx: Extract shouldExcludeTransactionErrors = false and forward it through narrowForwardedProps and wideForwardedProps.

  3. In src/components/TransactionItemRow/TransactionItemRowNarrow.tsx & TransactionItemRowWide.tsx: Forward shouldExcludeTransactionErrors to <DeferredTransactionItemRowRBR>.

  4. In src/components/TransactionItemRow/TransactionItemRowRBR.tsx:

    • Accept shouldExcludeTransactionErrors?: boolean in TransactionItemRowRBRProps and TransactionItemRowRBRInnerProps.
    • In TransactionItemRowRBRInner: When shouldExcludeTransactionErrors is true, filter transaction.errors before passing to ViolationsUtils.getRBRMessages to exclude plain string message errors (typeof errorValue === 'string') and server-attached receipt error messages (isReceiptError(errorValue) && errorValue.message?.trim()):
      const transactionForRBR = useMemo(() => {
          if (!shouldExcludeTransactionErrors || !transaction?.errors) {
              return transaction;
          }
      
          const filteredErrors = Object.fromEntries(
              Object.entries(transaction.errors).filter(([, errorValue]) => {
                  if (typeof errorValue === 'string') {
                      return false;
                  }
                  if (isReceiptError(errorValue) && errorValue.message?.trim()) {
                      return false;
                  }
                  return true;
              }),
          );
      
          return {
              ...transaction,
              errors: filteredErrors,
          };
      }, [shouldExcludeTransactionErrors, transaction]);
      
    • In TransactionItemRowRBR: Update the early-return check to evaluate hasVisibleTransactionErrors so that when shouldExcludeTransactionErrors is true and no violations, missing fields, or thread errors exist, the component returns null immediately and mounts zero DOM nodes.
  5. In src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx: Pass shouldExcludeTransactionErrors to <TransactionItemRow />.

What alternative solutions did you explore? (Optional)?

  • Passing shouldShowErrors={false} from MoneyRequestReportTransactionItem: Rejected because shouldShowErrors={false} completely suppresses <DeferredTransactionItemRowRBR>, which would hide legitimate policy violations (e.g., category required, receipt missing, out of policy limit), missing field errors, and transaction thread errors.
  • Removing ErrorMessageRow and relying solely on RBR: Rejected because RBR is an inline indicator that lacks a dismiss affordance (clearError). The dismissible error row is standard across report transaction views.

What are the regression risks and how will you mitigate them?

  • Search and other transaction lists: In Search table views and unreported expense lists, MoneyRequestReportTransactionItem is not used. TransactionItemRow defaults shouldExcludeTransactionErrors = false, preserving 100% of existing RBR behavior where no external ErrorMessageRow is present.
  • Policy violations and thread errors: Policy violations (violations), missing fields (missingFieldError), and action thread errors (transactionThreadActions) remain untouched and continue to render in RBR as expected.
  • Mitigation: Verified with comprehensive automated unit tests in MoneyRequestReportTransactionItemRejectErrorTest.tsx.

Automated Tests?

Add the following test cases to tests/ui/MoneyRequestReportTransactionItemRejectErrorTest.tsx:

    it('should show server creation/reconnection error once under the row, not duplicated in RBR', async () => {
        // Given an expense with a server rejection error string
        const serverErrorMessage = 'new expenses cannot be added to this report';
        const transactionWithServerError = buildTransaction({
            errors: {[ERROR_TIMESTAMP]: serverErrorMessage},
        });
        await renderTransactionItem(transactionWithServerError);

        // Then: The error message is rendered exactly once by ErrorMessageRow and not duplicated in RBR
        expect(screen.getAllByText(serverErrorMessage)).toHaveLength(1);
        expect(screen.queryByTestId('TransactionItemRowRBR')).not.toBeOnTheScreen();
    });

    it('should show server scanned receipt error once under the row without duplicating in RBR', async () => {
        // Given a scanned expense with a server error message preserved in ReceiptError
        const serverErrorMessage = 'new expenses cannot be added to this report';
        const transactionWithReceiptServerError = buildTransaction({
            errors: {
                [ERROR_TIMESTAMP]: serverErrorMessage,
                receipt: {message: serverErrorMessage, receiptID: 123},
            },
        });
        await renderTransactionItem(transactionWithReceiptServerError);

        // Then: The error message is rendered exactly once by ErrorMessageRow and not duplicated in RBR
        expect(screen.getAllByText(serverErrorMessage)).toHaveLength(1);
        expect(screen.queryByTestId('TransactionItemRowRBR')).not.toBeOnTheScreen();
    });

Manual Test Steps?

  1. Create a workspace with Account A as member and Account B as approver.
  2. As Account A, create an expense and submit the report to Account B.
  3. As Account A, enable Troubleshoot > Force offline.
  4. As Account B, open and approve the submitted report.
  5. As Account A (offline), add a manual expense and a scanned receipt expense to the report.
  6. As Account A, disable Force offline.
  7. Verify that each failed expense displays the server rejection error ("new expenses cannot be added to this report") exactly once in the dismissible error container with an [X] button, and that no duplicate red bullet error text is rendered in the row.
  8. Click [X] on the error container and verify that the error dismisses cleanly.

Contributor Details?

  • GitHub Username: @kevinjosh10
  • Email: [email protected]
  • Upwork Profile: https://www.upwork.com/freelancers/~0131dae36abcf59374

kevinjosh10 avatar Nov 26 '26 07:11 kevinjosh10

Proposal

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

After adding a manual expense and a scanned receipt expense offline to an already-approved workspace report and reconnecting, the report's expense list renders the server rejection "new expenses cannot be added to this report" twice for each failed expense instead of once.

What is the root cause of that problem?

Two separate components inside the same report-table row independently display the same server rejection message:

  1. MoneyRequestReportTransactionItem.tsx#L181-L194 extracts plain-string entries from transaction.errors, selects the single error to show via rejectErrorKey ? rejectError : getLatestErrorMessageField({errors: messageErrors}), and renders it in <ErrorMessageRow errors={transactionErrors} onDismiss={dismissTransactionError} />.
  2. Right above it, <TransactionItemRow> keeps shouldShowErrors = true, so both wide (TransactionItemRowWide.tsx#L827-L836) and narrow (TransactionItemRowNarrow.tsx#L196-L207) rows mount TransactionItemRowRBR.
  3. TransactionItemRowRBR.tsx#L76-L90 calls ViolationsUtils.getRBRMessages → extractErrorMessages, which merges both transaction.errors (plain strings and ReceiptError.message) and transactionThreadActions (action.errors) into uniqueMessages. Since #107654, reconcileFailureDataWithServerErrors.ts#L42-L79 preserves the server rejection string across transactions_*, ReceiptError.message, and reportActions_*. Because extractErrorMessages only deduplicates within the RBR string and has no knowledge of what ErrorMessageRow is already rendering underneath the same row, the server rejection renders twice (once in TransactionItemRowRBR, once in ErrorMessageRow).

Why filtering all string entries out of transaction.errors in TransactionItemRowRBR (as in the earlier proposal) is fragile:

  • Misses thread-action errors: extractErrorMessages (ViolationsUtils.ts#L514-L520) also merges transactionThreadActions (action.errors), and reconcileFailureDataWithServerErrors explicitly handles server errors on reportActions_*. Stripping transaction.errors alone cannot deduplicate a matching server rejection present on an action in transactionThreadActions.
  • Drops non-displayed errors when rejectErrorKey or multiple distinct errors exist: ErrorMessageRow renders at most one message (rejectErrorKey ? rejectError : getLatestErrorMessageField({errors: messageErrors}), MoneyRequestReportTransactionItem.tsx#L193). Blindly dropping every plain string in transaction.errors inside TransactionItemRowRBR hides errors that ErrorMessageRow is not currently displaying (for example, when rejectErrorKey overrides messageErrors with couldNotRejectExpense, or when an older distinct error exists alongside a newer one).
  • Duplicates filtering heuristics: Re-implementing typeof entry[1] === 'string' + ReceiptError.message matching in TransactionItemRowRBR splits display ownership across two files instead of using the rendered ErrorMessageRow messages as the single source of truth.

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

Deduplicate RBR messages against the exact message(s) ErrorMessageRow is already displaying for that row, using MoneyRequestReportTransactionItem as the single source of truth:

  1. Derive the exact displayed message list in MoneyRequestReportTransactionItem.tsx#L193-L195:

    • Extract displayedErrorMessages: string[] from transactionErrors (specifically, when !rejectErrorKey, take the non-empty trimmed string values of transactionErrors—which is at most the single latest string error rendered by ErrorMessageRow; when rejectErrorKey is set, leave it empty so couldNotRejectExpense never hides unrelated string errors).
    • Pass excludedErrorMessages={displayedErrorMessages} (only when non-empty) into <TransactionItemRow>.
  2. Forward optional excludedErrorMessages?: string[] through TransactionItemRow → TransactionItemRowWide / TransactionItemRowNarrow → DeferredTransactionItemRowRBR → TransactionItemRowRBR:

    • Default to undefined so Search rows and all other callers of TransactionItemRow remain completely unchanged.
    • Pass excludedErrorMessages into ViolationsUtils.getRBRMessages in TransactionItemRowRBR.tsx#L76-L90.
    • Because TransactionItemRowRBRInner already returns RBRMessages.length > 0 && (...) (#L93-L95), when all extracted error messages are excluded and there are no violations or missingFieldError, no empty RBR container is mounted.
  3. Filter matching messages at the single extraction point in ViolationsUtils.ts#L509-L545 and #L1397-L1429:

    • Accept optional excludedErrorMessages?: string[] on getRBRMessages and forward it to extractErrorMessages.
    • Normalize excludedErrorMessages into a trimmed Set<string> and omit any extracted message whose .trim() is in that set before returning Array.from(uniqueMessages).
    • This single check handles all three duplicate vectors uniformly:
      • transaction.errors plain string (manual expense),
      • ReceiptError.message populated by reconcileFailureDataWithServerErrors (scanned receipt expense), and
      • identical server error strings on transactionThreadActions (action.errors).
    • Meanwhile, generic receipt upload failures (where ReceiptError.message is empty and falls back to iou.error.receiptFailureMessageShort), distinct error strings, missingFieldError, violations, per-expense errors across multiple failed rows, and ErrorMessageRow dismissal (clearError in src/libs/actions/Transaction.ts#L763-L770) all continue working unchanged.
  4. Tests:

    • Extend tests/unit/ViolationUtilsTest.ts (describe('getRBRMessages')) to verify excludedErrorMessages:
      • omits matching string error, matching ReceiptError.message, and matching transactionThreadActions error;
      • retains violations, missingFieldError, non-matching distinct error strings, and generic ReceiptError without a server message.
    • Extend tests/ui/TransactionItemRowRBRTest.tsx and add a full report-row UI test alongside tests/ui/MoneyRequestReportTransactionItemRejectErrorTest.tsx verifying:
      • a failed manual expense and a failed scanned expense in MoneyRequestReportTransactionItem each render "new expenses cannot be added to this report" exactly once (inside dismissible ErrorMessageRow) in both wide and narrow layouts;
      • two failed expenses on the same report each keep their own error row;
      • a row with both a server rejection and a violation renders the rejection once in ErrorMessageRow and the violation in TransactionItemRowRBR;
      • a row with rejectErrorKey does not lose unrelated RBR errors.

What alternative solutions did you explore? (Optional)

  • Boolean shouldExcludeTransactionStringErrors flag filtering transaction.errors in TransactionItemRowRBR (prior proposal): Rejected because it misses matching errors from transactionThreadActions, silently drops non-displayed string errors when rejectErrorKey or multiple distinct errors exist, and duplicates MoneyRequestReportTransactionItem's error-selection logic.
  • Passing shouldShowErrors={false} to TransactionItemRow: Rejected because it suppresses violations and missingFieldError in report rows.
  • Removing ErrorMessageRow from MoneyRequestReportTransactionItem: Rejected because it removes the dismiss (X) button wired to clearError and breaks reject-error display.

Contributor details

Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01aee0111e1a0ae483

admin0330 avatar Nov 26 '26 07:11 admin0330

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 26 '26 07:11 melvin-bot[bot]

Proposal

What is the root cause of that problem?

Each failed expense row in the report table shows transaction.errors in two places, and nothing stops them from showing the same message.

  1. The row's own error line. MoneyRequestReportTransactionItem keeps the string entries of transaction.errors, picks the latest one, and renders it in <ErrorMessageRow> with the X.
  2. The row's warning line. The <TransactionItemRow> just above it uses the default shouldShowErrors = true, so the wide and narrow rows mount TransactionItemRowRBR. It calls getRBRMessages, which runs extractErrorMessages(transaction.errors, …) and adds every string again.

The row's own error line was added in #92860 ("dismiss the failed expense row when the user dismisses the error message"). The warning line already showed transaction.errors, and it was not told to skip what the new line shows.

Proof from the bug video (about 1:56-2:00): each failed row has a small faded line inside the row (the warning line, faded by offlineFeedbackPending) and a second line under it with the X (the error line). Same expense, same text.

This is not new with #107654. The client error for a failed manual expense is already a plain translated string: getMicroSecondOnyxErrorWithTranslationKey returns translate(...), and it is written to transaction.errors by the failure data through getReceiptError. So any failed manual expense on this page shows its error twice, for example "Unexpected error submitting this expense. Please try again later." #107654 only made both lines carry the same server text (reconcileErrorsField also copies it into the scan's ReceiptError.message), which made it easy to see.

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

Keep the row's error line as the single owner of the message it shows, because it has the dismiss X. Make the warning line skip exactly the text that the error line already shows. Everything else stays in the warning line.

  1. In MoneyRequestReportTransactionItem, take the text that the error line shows from transactionErrors (its string values) and pass it to TransactionItemRow as a new optional prop, for example errorMessagesShownInRow: string[].
  2. Pass the prop through TransactionItemRow → wide and narrow rows → DeferredTransactionItemRowRBR → TransactionItemRowRBR → getRBRMessages. Default is an empty list, so Search, Insights, Duplicate and Merge rows do not change.
  3. In getRBRMessages, after extractErrorMessages, drop any message whose trimmed text is in that list:
errorMessages = extractErrorMessages(...)
    .filter(message => !errorMessagesShownInRow.includes(message.trim()))

Why filter by text and not by error type:

  • It removes all copies of the shown text in one place: the plain string, the scan's ReceiptError.message copy, and a thread action error with the same text.
  • It keeps messages the error line does not show. The error line shows only the latest string, and when a reject error exists it shows only the reject message (L192-L193). Dropping all string errors from the warning line would make those messages disappear from the row.
  • Violations, missing-field errors and the generic receipt failure text are not affected.

Tests:

  • Add cases to TransactionItemRowRBRTest: a shown message is skipped; a different string, a violation and a receipt error without a message still show.
  • Unit test for getRBRMessages with the new list.
  • QA: the steps in this issue (manual and scan each show the message once, X still clears it, scan keeps Try again / Save in the expense view), plus a failed manual expense with the generic error.

What alternative solutions did you explore? (Optional)

  • Pass shouldShowErrors={false} to TransactionItemRow from the report table. Rejected: it also hides violations and missing-field errors.
  • Remove ErrorMessageRow and keep only the warning line. Rejected: it removes the X that clears the failed expense (#92860).
  • Drop every plain string error from the warning line. Rejected: it hides older errors and string errors on a row with a reject error, which the error line does not show.
  • Fix it in reconcileFailureDataWithServerErrors. Rejected: the data is already correct (one string per expense); the duplicate is in the view, and it also happens for the generic error that never goes through that helper.

mattlsyyssll avatar Nov 26 '26 07:11 mattlsyyssll

@ShridharGoel can you check this?

mountiny avatar Nov 27 '26 04:11 mountiny

Sure, this is an existing issue on prod as well

ShridharGoel avatar Nov 27 '26 04:11 ShridharGoel

Proposal

What is the root cause of that problem?

On current main, MoneyRequestReportTransactionItem.tsx:197-201 already strips plain-string messageErrors from rowTransaction.errors, which fixes manual expenses. However, scanned receipt expenses still show "new expenses cannot be added to this report" twice:

  1. reconcileFailureDataWithServerErrors.ts:21-22 copies the server rejection string into ReceiptError.message, while the server's onyxData also stores that same string in transaction.errors.
  2. MoneyRequestReportTransactionItem.tsx:198-201 keeps all object entries in receiptErrors and passes them via rowTransaction to TransactionItemRow.
  3. ViolationsUtils.ts:528-531 reads ReceiptError.message from rowTransaction.errors, so TransactionItemRowRBR renders the exact same rejection message directly above <ErrorMessageRow>.

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

In src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx:197-201:

  • Collect the trimmed string error messages currently shown by <ErrorMessageRow> (transactionErrors).
  • When building receiptErrors for rowTransaction, skip any ReceiptError whose message?.trim() is already in that set.
  • Keep ordinary receipt upload errors (without a matching ErrorMessageRow string) unchanged, and add a unit test for the scanned-expense server rejection case.

What alternative solutions did you explore? (Optional)

  • Removing message: serverError from reconcileFailureDataWithServerErrors.ts:22 would regress views without a separate <ErrorMessageRow> (such as Search rows) that rely on ReceiptError.message.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~019e72f237c6f31e66

furkanorbeyi avatar Nov 27 '26 12:11 furkanorbeyi

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 27 '26 12:11 melvin-bot[bot]

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