Skip to content

Add Try again logic for track expense flow - #103487

Open
rinej wants to merge 2 commits into
Expensify:mainfrom
callstack-internal:receipt-upload-retry-track-expense
Open

rinej wants to merge 2 commits into
Expensify:mainfrom
callstack-internal:receipt-upload-retry-track-expense

Conversation

@rinej

@rinej rinej commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Follow-up to #99902 and #102893, which added Try again for failed RequestMoney and ReplaceReceipt uploads. A scanned receipt tracked in the self-DM goes through TrackExpense, so when the upload fails - the row showed only Save before.

This PR adds Try again for a failed TrackExpense in the self-DM

Fixed Issues

$ #102494
PROPOSAL:

Tests

  1. Go to Settings > Troubleshoot and turn on Simulate failing network requests.
  2. Go to your self-DM, press + > Create expense > Scan, and choose a receipt from the gallery.
  3. Open the expense. Verify the receipt error row shows Try again and Save.
  4. Turn off Simulate failing network requests and return to the expense.
  5. Press Try again. Verify the error goes away and the self-DM has one tracked expense

Offline tests

QA Steps

Same as Tests

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

TrackExpense-SelfDM.mp4
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@rinej
rinej marked this pull request as ready for review October 8, 2026 16:14
@rinej
rinej requested review from a team as code owners October 8, 2026 16:14
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...nents/ReportActionItem/MoneyRequestReceiptView.tsx 72.05% <ø> (+0.10%) ⬆️
...ibs/ReceiptUploadRetryHandler/buildRetryPayload.ts 81.81% <ø> (ø)
src/libs/actions/IOU/TrackExpense.ts 85.80% <100.00%> (+0.49%) ⬆️
src/libs/ReceiptUploadRetryHandler/index.ts 76.08% <83.33%> (+1.08%) ⬆️
...ploadRetryHandler/buildTrackExpenseRetryPayload.ts 88.88% <88.88%> (ø)
... and 134 files with indirect coverage changes

@melvin-bot
melvin-bot Bot requested review from brunovjk and joekaufmanexpensify and removed request for a team and joekaufmanexpensify October 8, 2026 16:14
@melvin-bot

melvin-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown

@brunovjk Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

policyParams,
transactionParams: {
amount: details.amount,
currency: details.currency,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-3 (docs)

The transaction-detail extraction, receipt construction, and the entire transactionParams object (amount, currency, created, merchant, comment, category, tag, taxCode, taxAmount, billable, reimbursable, attendees, isFromGlobalCreate, receipt) are duplicated verbatim from buildRetryPayload.ts (lines 102-133), including the identical // Read from the transaction because details widens this to string | Attendee[]. comment. You already extracted the shared predicate/participant helpers into buildRetryPayload.ts and import them here; this block is the remaining DRY gap. If the shape of a tracked expense's transaction params ever changes, both builders have to be edited in lockstep.

Extract the shared block into a helper exported alongside the others, e.g.:

// in buildRetryPayload.ts
function buildRetryTransactionParams(transaction: Transaction, details: TransactionDetails, receipt: Receipt) {
    return {
        amount: details.amount,
        currency: details.currency,
        created: details.created,
        merchant: getMerchantForRetry(details.merchant),
        comment: details.comment,
        category: details.category,
        tag: details.tag,
        taxCode: details.taxCode,
        taxAmount: details.taxAmount,
        billable: details.billable,
        reimbursable: details.reimbursable,
        // Read from the transaction because `details` widens this to `string | Attendee[]`.
        attendees: transaction.comment?.attendees,
        isFromGlobalCreate: getIsFromGlobalCreate(transaction),
        receipt,
    };
}
export {buildRetryTransactionParams};

Then call transactionParams: buildRetryTransactionParams(transaction, details, receipt) in both builders.


Reviewed at: c237890 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant