Skip to content

[WIP] Migrate submit-expense write scheduling to API.writeWhenReady and delete deferredLayoutWrite - #98658

Closed
JakubKorytko wants to merge 19 commits into
Expensify:mainfrom
software-mansion-labs:korytko/submit-expense-writewhenready-migration
Closed

JakubKorytko wants to merge 19 commits into
Expensify:mainfrom
software-mansion-labs:korytko/submit-expense-writewhenready-migration

Conversation

@JakubKorytko

Copy link
Copy Markdown
Member

Explanation of Change

Deletes the deferredLayoutWrite/submitWriteSession write registry. Each IOU action now calls API.writeWhenReady directly with a barrier: API.armTransitionBarrier for dismiss-modal paths, Search's own barrier (pendingSearchWrite) for Search. The two "is a submit in flight" UI signals move to small modules that own no write timing. No write is scheduled later than before.

Fixed Issues

$ #96010
PROPOSAL: N/A

Tests

1. Submit an expense that lands on Search (the Search-barrier path)

  1. Open the Reports tab from the bottom tab bar (wide screens: the left navigation) and wait for the list to finish loading.
  2. Tap the green + button and choose Create expense.
  3. Enter an amount, tap Next, pick any workspace or member as the recipient.
  4. On the confirmation screen, tap Create expense.
  5. Verify that the modal closes, a placeholder (greyed) row appears at the top of the Reports list, and it is replaced by the real expense row a moment later.
  6. Verify that the list never flashes an empty state ("no results" copy) between the modal closing and the row appearing.
  7. Verify that the new expense is present after pulling to refresh / reloading the page, i.e. the request actually reached the server.

2. Submit an expense that lands on a report (the transition-barrier path)

  1. Open the Inbox tab and open a 1:1 chat with another member that has no expenses in it yet.
  2. From that chat, use the + button in the composer and choose Create expense.
  3. Enter an amount and tap Next, then Create expense on the confirmation screen.
  4. Verify that the modal slides out smoothly, without a visible stutter mid-animation.
  5. Verify that while the animation finishes, the destination report shows a loading skeleton rather than the "empty report" state or the empty-state animation.
  6. Verify that the expense preview appears in the report immediately after the animation completes.
  7. Repeat steps 2-6 on a narrow window / phone, where the destination is revealed before the modal dismisses, and verify the same result.

3. Split an expense from Search (several writes on one barrier)

  1. Open the Reports tab.
  2. Tap the green + button and choose Split expense.
  3. Add at least two participants, enter an amount, tap Next, then confirm the split.
  4. Verify that the modal closes and every resulting expense appears in the list, with no empty state flashing in between.
  5. Verify that all the split expenses survive a page reload.

Offline tests

  1. Turn off your network connection.
  2. Repeat Test 1 (submit an expense from the Reports tab).
  3. Verify that the expense appears in the list immediately with the greyed-out pending styling, and that no empty state is shown in between.
  4. Turn the network back on.
  5. Verify that the expense loses the pending styling and stays in the list, i.e. the queued request was sent once the connection returned.
  6. Repeat Test 2 offline and verify the destination report shows the expense optimistically, with pending styling, and that it settles once back online.

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

…barrier instead of the DISMISS_MODAL channel
@codecov

codecov Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/CONST/index.ts 94.85% <ø> (ø)
src/hooks/useSearchOverlay.tsx 55.88% <100.00%> (ø)
src/hooks/useSearchPageSetup.ts 92.30% <100.00%> (ø)
src/libs/API/index.ts 91.80% <100.00%> (+0.27%) ⬆️
src/libs/API/writeWhenReady.ts 98.78% <100.00%> (+2.11%) ⬆️
src/libs/IOUAmountSubmission.ts 86.70% <100.00%> (-0.08%) ⬇️
src/libs/MoneyRequestReportUtils.ts 88.88% <100.00%> (ø)
...on/helpers/markPendingSearchWriteIfGlobalCreate.ts 100.00% <100.00%> (ø)
.../libs/Navigation/helpers/submitWithDismissFirst.ts 79.06% <100.00%> (ø)
src/libs/actions/IOU/MoneyRequestBuilder.ts 90.23% <ø> (ø)
... and 20 more
... and 39 files with indirect coverage changes

@JakubKorytko

Copy link
Copy Markdown
Member Author

Closing in favor of split, 1st part here

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