Skip to content

[Payment due @marufsharifi] No proactive transaction thread creation for CreateDistanceRequest and CreatePerDiemRequest - #96492

Merged
Valforte merged 4 commits into
mainfrom
ionatan_splitnoproactivethread
Jul 21, 2026
Merged

Valforte merged 4 commits into
mainfrom
ionatan_splitnoproactivethread

Conversation

@iwiznia

@iwiznia iwiznia commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This goes in hand with https://github.com/Expensify/Auth/pull/23059 we don't need to block, but both need to be deployed for this to work

Fixed Issues

$https://github.com/Expensify/Expensify/issues/428920
PROPOSAL:

Tests

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

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.
  • 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

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/libs/actions/IOU/PerDiem.ts 68.48% <ø> (ø)
src/libs/actions/IOU/Split.ts 72.24% <ø> (ø)
... and 9 files with indirect coverage changes

@iwiznia
iwiznia requested a review from Valforte July 20, 2026 17:31
@iwiznia
iwiznia marked this pull request as ready for review July 20, 2026 17:31
@iwiznia
iwiznia requested review from a team as code owners July 20, 2026 17:31
@melvin-bot
melvin-bot Bot requested review from heyjennahay and marufsharifi and removed request for a team July 20, 2026 17:31
@melvin-bot

melvin-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

@marufsharifi 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]

@marufsharifi

marufsharifi commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-07-21.at.12.12.32.AM.mov
Screen.Recording.2026-07-21.at.12.14.56.AM.mov

Comment on lines +479 to +480
// The backend creates the transaction thread itself and syncs it back via Onyx updates, so the client doesn't build it optimistically or pass its reportID to the API.
shouldGenerateTransactionThreadReport: false,

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.

Confirm before merge — per diem is a different backend command than distance.

This disables proactive thread creation for per diem, but per diem goes through CreatePerDiemRequest, not CreateDistanceRequest (src/libs/API/types.ts:232 vs :242). The PR title and description only mention CreateDistanceRequest.

If Auth PR #23059 only makes CreateDistanceRequest build the thread server-side, per-diem expenses will end up with no transaction thread at all — the client stops creating it optimistically and the old backend won't create it either. Users then can't open or comment on the per-diem transaction thread, and it won't surface as a JS console error (so the current Tests section won't catch it).

Please confirm #23059 also covers CreatePerDiemRequest, and update the title/description to include per diem — or split per diem into its own PR until the backend is ready.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This disables proactive thread creation for per diem, but per diem goes through CreatePerDiemRequest, not CreateDistanceRequest (src/libs/API/types.ts:232 vs :242). The PR title and description only mention CreateDistanceRequest.

Oh yea, I initially started only with CreateDistanceRequest but then realized CreatePerDiemRequest was also affected.

If Auth PR #23059 only makes CreateDistanceRequest build the thread server-side, per-diem expenses will end up with no transaction thread at all — the client stops creating it optimistically and the old backend won't create it either. Users then can't open or comment on the per-diem transaction thread, and it won't surface as a JS console error (so the current Tests section won't catch it).

It changes both APIs and to clarify the thread is created lazily on first access (OpenReport on open, EditMoneyRequest on edit, comments via get-or-create). So users can open/comment fine.

Updated the title.

odometerStart,
odometerEnd,
},
shouldGenerateTransactionThreadReport: false,

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.

Unconditional false — deploy ordering is the only safety net.

There's no beta/flag here, so this takes effect the instant it ships. If App deploys before Auth #23059 is live, every distance (and per-diem) expense created in that window has no transaction thread until something backfills it.

This matches the existing pattern (useExpenseSubmission.ts:205 and IOUAmountSubmission.ts:365 also hard-code false), so a beta isn't strictly required — but those already had backend support. Since this one is a co-deploy, please gate on ordering: land/deploy this only after #23059 is confirmed live on the same environment. The description's "doesn't need to block" is the risk worth double-checking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, really everything is fine. Both PRs are needed for the thread to not be created, but:

  • App ships first (Auth still old): App omits the ID, then old Auth (shouldCreate=true) creates the thread server-side.
  • Auth ships first (App still old): App still sends the optimistic ID, then new Auth uses it.


// STEP 5: Build Onyx Data
const {optimisticData, successData, failureData} = buildOnyxDataForMoneyRequest({
shouldGenerateTransactionThreadReport: false,

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.

No regression test for the changed optimistic data (diff coverage = 0%).

This change alters the shape of the optimistic Onyx data (whether a transaction thread report + its CREATED action are written) — exactly the kind of thing a unit test catches cheaply and manual QA misses.

Suggested test alongside the existing IOU builder specs:

it('per diem / distance creation does not optimistically create a transaction thread', () => {
    const {transactionThreadReportID, createdReportActionIDForThread, onyxData} = /* invoke builder */;
    expect(transactionThreadReportID).toBeUndefined();
    expect(createdReportActionIDForThread).toBeUndefined();
    // and: no optimistic REPORT / REPORT_ACTIONS write for a transaction thread
});

This applies equally to the createDistanceRequest path (Split.ts:2135).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added new tests

@iwiznia iwiznia changed the title No proactive transaction thread creation for CreateDistanceRequest No proactive transaction thread creation for CreateDistanceRequest and CreatePerDiemRequest Jul 21, 2026
@iwiznia
iwiznia requested a review from marufsharifi July 21, 2026 11:12

@marufsharifi marufsharifi left a comment

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.

LGTM

@melvin-bot melvin-bot Bot changed the title No proactive transaction thread creation for CreateDistanceRequest and CreatePerDiemRequest [Payment due @marufsharifi] No proactive transaction thread creation for CreateDistanceRequest and CreatePerDiemRequest Jul 21, 2026
@melvin-bot

melvin-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🎯 @marufsharifi, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - https://www.github.com/Expensify/Expensify/issues/428920.

If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created.

…ivethread

# Conflicts:
#	tests/actions/IOUTest/SplitTest.ts
@Valforte
Valforte merged commit 6dba2d4 into main Jul 21, 2026
42 checks passed
@Valforte
Valforte deleted the ionatan_splitnoproactivethread branch July 21, 2026 12:22
@github-actions

Copy link
Copy Markdown
Contributor

🚧 Valforte has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/Valforte in version: 9.4.42-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Help site review: no docs changes required.

I reviewed the changes in this PR and they do not require any updates to the help site articles under App/docs/articles.

Why: This PR only changes who creates the transaction thread for CreateDistanceRequest and CreatePerDiemRequest — it stops the client from optimistically building the transaction thread and lets the backend create it lazily when first needed (paired with Auth#23059). The diff is limited to internal action logic (src/libs/actions/IOU/PerDiem.ts, src/libs/actions/IOU/Split.ts) and their tests. There is no change to user-facing behavior, UI, feature names, or workflows — transaction threads still appear and behave exactly as before from a user's perspective.

The relevant help articles (e.g. Per-Diem-Expenses.md, Distance-Expenses.md, Split-Expenses.md) document how to create and manage these expenses, not the internal mechanism of transaction-thread creation, so none of them are affected.

Since no help site content needs to change, I did not create a draft docs PR (there is no linked help site PR to review). If you believe there's a user-facing behavior change I missed, let me know and I'll take another look.

@IuliiaHerets

Copy link
Copy Markdown

Hi @iwiznia. Any QA steps here?

cc @Valforte @heyjennahay @marufsharifi

@iwiznia

iwiznia commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

No, regression tests should cover this

@melvin-bot

melvin-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🤖 Payment issue created: #96788

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.4.42-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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.

7 participants