Skip to content

[Part 3]: Using buildNextStepNew function in IOU.ts#73816

Merged
danieldoglas merged 24 commits intoExpensify:mainfrom
DylanDylann:refactor-808
Nov 6, 2025
Merged

[Part 3]: Using buildNextStepNew function in IOU.ts#73816
danieldoglas merged 24 commits intoExpensify:mainfrom
DylanDylann:refactor-808

Conversation

@DylanDylann
Copy link
Contributor

@DylanDylann DylanDylann commented Oct 30, 2025

Explanation of Change

Fixed Issues

$ #66365
$ #66366
$ #66367
$ #66368
PROPOSAL:

Tests

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Enable advanced approval workflow
  2. Add the second approval
  3. Create an expense
  4. Submit expense
  5. Verify that the next step display correctly
  6. Login as the first approval and approve the expense
  7. Verify that the next step display correctly
  8. Login as the second approval and approve the expense
  9. Verify that the next step display correctly
  10. Login as the admin and pay the expense
  11. Verify that the next step display correctly
  • 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
    • MacOS: Desktop
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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 a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

Screen.Recording.2025-10-20.at.15.38.22.mov
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

@DylanDylann DylanDylann requested a review from a team as a code owner October 30, 2025 08:48
@melvin-bot melvin-bot bot requested review from jjcoffee and removed request for a team October 30, 2025 08:48
@melvin-bot
Copy link

melvin-bot bot commented Oct 30, 2025

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

@DylanDylann
Copy link
Contributor Author

@jjcoffee Please ignore this PR, @allgandalf will review it

@DylanDylann DylanDylann marked this pull request as draft October 30, 2025 08:50
@allgandalf allgandalf requested review from allgandalf and removed request for jjcoffee October 30, 2025 09:13
@allgandalf
Copy link
Contributor

let me know once this is ready for review

@DylanDylann DylanDylann marked this pull request as ready for review October 30, 2025 17:31
@DylanDylann
Copy link
Contributor Author

Continue working on it tomorrrow

@github-actions
Copy link
Contributor

Code Review Summary

Files Reviewed: 18

  • src/components/MoneyReportHeaderStatusBar.tsx
  • src/components/ReportActionItem/MoneyRequestView.tsx
  • src/hooks/useDeleteTransactions.ts
  • src/libs/NextStepUtils.ts
  • src/libs/actions/IOU.ts
  • src/pages/AddUnreportedExpense.tsx
  • src/pages/Share/SubmitDetailsPage.tsx
  • src/pages/iou/SplitExpensePage.tsx
  • src/pages/iou/request/step/IOURequestStepAmount.tsx
  • src/pages/iou/request/step/IOURequestStepConfirmation.tsx
  • src/pages/iou/request/step/IOURequestStepDate.tsx
  • src/pages/iou/request/step/IOURequestStepDistance.tsx
  • src/pages/iou/request/step/IOURequestStepDistanceManual.tsx
  • src/pages/iou/request/step/IOURequestStepDistanceMap.tsx
  • src/pages/iou/request/step/IOURequestStepScan/index.native.tsx
  • src/pages/iou/request/step/IOURequestStepScan/index.tsx
  • tests/actions/IOUTest.ts
  • tests/unit/NextStepUtilsTest.ts

Issues Found: 1

PERF-6 Violation: Missing Dependency in useMemo Hook

File: src/components/MoneyReportHeaderStatusBar.tsx
Line: 34

Issue: The useMemo hook uses currentUserPersonalDetails.email inside the callback, but the dependency array only includes nextStep?.message and is missing currentUserPersonalDetails.email.

Current Code:

const messageContent = useMemo(() => {
    const messageArray = nextStep?.message;
    return parseMessage(messageArray, currentUserPersonalDetails.email ?? '');
}, [nextStep?.message]);

Fix:

const messageContent = useMemo(() => {
    const messageArray = nextStep?.message;
    return parseMessage(messageArray, currentUserPersonalDetails.email ?? '');
}, [nextStep?.message, currentUserPersonalDetails.email]);

Reasoning: Passing entire objects as dependencies causes hooks to re-execute whenever any property changes, even unrelated ones. Specifying individual properties creates more granular dependency tracking, reducing unnecessary hook executions and improving performance predictability.

Overall Assessment

The PR is a large refactoring effort to replace the deprecated buildNextStep function (which uses Onyx.connect) with the new buildNextStepNew function. The changes properly pass user context parameters through the call chain instead of relying on global state, which is a good architectural improvement.

The code quality is generally good, with proper parameter typing and consistent patterns. The only issue found is a missing dependency in a useMemo hook that could lead to stale data being displayed when the user's email changes.

@DylanDylann
Copy link
Contributor Author

@allgandalf Ready for your review

@allgandalf
Copy link
Contributor

jests are failing

@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 26.54867% with 83 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/libs/actions/IOU.ts 60.00% 12 Missing ⚠️
...c/components/ReportActionItem/MoneyRequestView.tsx 0.00% 7 Missing ⚠️
src/pages/TransactionMerge/ConfirmationPage.tsx 0.00% 5 Missing ⚠️
src/pages/iou/SplitExpensePage.tsx 0.00% 5 Missing ⚠️
...rc/pages/iou/request/step/IOURequestStepAmount.tsx 0.00% 4 Missing ⚠️
.../pages/iou/request/step/IOURequestStepDistance.tsx 0.00% 4 Missing ⚠️
.../iou/request/step/IOURequestStepDistanceManual.tsx 0.00% 4 Missing ⚠️
...ges/iou/request/step/IOURequestStepDistanceMap.tsx 0.00% 4 Missing ⚠️
...u/request/step/IOURequestStepScan/index.native.tsx 0.00% 4 Missing ⚠️
src/pages/AddUnreportedExpense.tsx 0.00% 3 Missing ⚠️
... and 16 more
Files with missing lines Coverage Δ
src/libs/actions/MergeTransaction.ts 55.55% <100.00%> (ø)
src/components/MoneyReportHeaderStatusBar.tsx 22.22% <0.00%> (ø)
src/hooks/useDeleteTransactions.ts 19.11% <80.00%> (+4.83%) ⬆️
src/libs/NextStepUtils.ts 72.51% <50.00%> (+2.79%) ⬆️
src/libs/actions/Report.ts 52.20% <50.00%> (ø)
src/libs/actions/Transaction.ts 46.88% <50.00%> (ø)
...s/iou/request/step/IOURequestStepTaxAmountPage.tsx 0.00% <0.00%> (ø)
.../pages/iou/request/step/IOURequestStepCategory.tsx 0.00% <0.00%> (ø)
src/pages/iou/request/step/IOURequestStepDate.tsx 0.00% <0.00%> (ø)
...es/iou/request/step/IOURequestStepDistanceRate.tsx 0.00% <0.00%> (ø)
... and 17 more

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DylanDylann
Copy link
Contributor Author

@allgandalf The failed UTs look unrelated. I will check again later. Please ignore it now

@trjExpensify
Copy link
Contributor

Code refactor PR, unassigning and unsubscribing. 👍

@trjExpensify trjExpensify removed their request for review November 5, 2025 00:01
@allgandalf
Copy link
Contributor

jest is failing

@allgandalf
Copy link
Contributor

more failures :)

@danieldoglas danieldoglas merged commit 5f102c8 into Expensify:main Nov 6, 2025
26 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Nov 6, 2025

🚀 Deployed to staging by https://github.com/danieldoglas in version: 9.2.46-0 🚀

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

NikkiWines added a commit that referenced this pull request Nov 7, 2025
This reverts commit 5f102c8, reversing
changes made to 4435bdd.
luacmartins added a commit that referenced this pull request Nov 7, 2025
Revert "Merge pull request #73816 from DylanDylann/refactor-808"
@vincdargento
Copy link

@DylanDylann This PR is failing because of a regression issue #74618
The issue is reproducible in: Web, mWeb

bug.mp4

luacmartins added a commit that referenced this pull request Nov 7, 2025
Revert "Merge pull request #73816 from DylanDylann/refactor-808"

(cherry picked from commit 327a5da)

(cherry-picked to staging by luacmartins)
@OSBotify
Copy link
Contributor

OSBotify commented Nov 7, 2025

🚀 Deployed to production by https://github.com/luacmartins in version: 9.2.46-3 🚀

platform result
🖥 desktop 🖥 success ✅
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 failure ❌

@OSBotify
Copy link
Contributor

OSBotify commented Nov 7, 2025

🚀 Deployed to staging by https://github.com/danieldoglas in version: 9.2.47-0 🚀

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

@allgandalf
Copy link
Contributor

@DylanDylann when can we expect a V2 PR?

DylanDylann added a commit to DylanDylann/App that referenced this pull request Nov 10, 2025
@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/cristipaval in version: 9.2.47-1 🚀

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

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.

6 participants