Skip to content

Update create transaction Manual flow to ask for merchant after asking for amount v3#82214

Closed
nkdengineer wants to merge 2 commits intoExpensify:mainfrom
nkdengineer:revert-82132-revert-80480-revert-80286-revert-76595-fix/76050
Closed

Update create transaction Manual flow to ask for merchant after asking for amount v3#82214
nkdengineer wants to merge 2 commits intoExpensify:mainfrom
nkdengineer:revert-82132-revert-80480-revert-80286-revert-76595-fix/76050

Conversation

@nkdengineer
Copy link
Contributor

@nkdengineer nkdengineer commented Feb 12, 2026

Explanation of Change

Update create transaction Manual flow to ask for merchant after asking for amount

Fixed Issues

$ #76050
PROPOSAL: #76050 (comment)

Tests

Pre-requisites

  • Have at least one workspace with a policy expense chat
  • Have access to a personal (P2P) chat
  • Set up a default workspace in settings

Test Case 1: Manual Expense from Workspace Chat (Primary Flow)

Steps:

  1. Open a workspace expense chat
  2. Tap the + button in the composer
  3. Select Create expenseManual tab
  4. Enter an amount (e.g., $50) and tap Next
  5. Expected: You should be navigated to the Merchant step
  6. Enter a merchant name and tap Save
  7. Expected: You should be navigated to the Confirmation page
  8. Tap the back button on the Confirmation page
  9. Expected: You should go back to the Merchant page (not Amount)
  10. Tap the back button on the Merchant page
  11. Expected: You should go back to the Amount page
  12. Enter an amount (e.g., $50) and tap Next
  13. Expected: You should be navigated to the Confirmation page

Test Case 2: Global Create with Default Workspace

Steps:

  1. Set a workspace as your default (Settings → Workspaces → select one as default)
  2. Tap the global + button
  3. Select Create expenseManual tab
  4. Enter an amount and tap Next
  5. Expected: You should be navigated to the Merchant step
  6. Enter a merchant and tap Save
  7. Expected: You should be navigated to the Confirmation page
  8. Tap the back button on the Confirmation page
  9. Expected: You should go back to the Merchant page (not Amount)
  10. Tap the back button on the Merchant page
  11. Expected: You should go back to the Amount page
  12. Enter an amount (e.g., $50) and tap Next
  13. Expected: You should be navigated to the Confirmation page

Test Case 3: Global Create without Default Workspace (Participants Flow)

Steps:

  1. Remove any default workspace or use an account with a personal policy only
  2. From any screen, tap the global + button
  3. Select Create expenseManual tab
  4. Enter an amount and tap Next
  5. Expected: You should be navigated to the Participants step
  6. Select a workspace expense chat as the participant
  7. Tap Next
  8. Expected: You should be navigated to the Merchant step
  9. Enter a merchant and tap Save
  10. Expected: You should be navigated to the Confirmation page
  11. Verify back navigation (Confirmation → Merchant → Participants)

Test Case 4: P2P (Personal) Transaction – No Merchant Step

Steps:

  1. Open a personal 1:1 chat (not a workspace chat)
  2. Tap the + button
  3. Select Create expenseManual tab
  4. Enter an amount and tap Next
  5. Expected: You should be navigated directly to the Confirmation page (no Merchant step)

Test Case 5: Scan Request – No Merchant Step

Steps:

  1. Open a workspace expense chat
  2. Tap the + button
  3. Select Create expenseScan tab
  4. Add a receipt
  5. Expected: You should be navigated to the Confirmation page (no Merchant step before confirmation)
  6. Repeat using the global + button → Participants → select a workspace
  7. Expected: There should still be no Merchant step for scan requests

Test Case 6: Participants – Select Personal Chat (No Merchant Step)

Steps:

  1. From global +Create expenseManual tab
  2. Enter an amount and tap Next
  3. On the Participants step, select a user (not a workspace)
  4. Tap Next
  5. Expected: You should be navigated directly to the Confirmation page (no Merchant step)

Test Case 7: Self DM Expense – Move to Workspace (Without Merchant)

Steps:

  1. Go to your Self DM (personal chat with yourself)
  2. Tap +Create expenseManual tab
  3. Enter an amount and complete the expense (without merchant)
  4. Tap it and choose Submit or Categorize to move it to a workspace
  5. Select a workspace
  6. Expected: You should be navigated to the Merchant step
  7. Tap the back button on the merchant page
  8. Expected: You should go back to the ** Participants** page
  9. Select a P2P chat
  10. Expected: You should be navigated to the Confirmation page
  11. Tap the back button on the Confirmation page
  12. Expected: You should go back to the Participants page (not Merchant)
  13. Select a workspace
  14. Expected: You should be navigated to the Merchant step

Test Case 8: Self DM Expense – Move to Workspace (With Merchant)

Steps:

  1. Go to your Self DM (personal chat with yourself)
  2. Tap +Create expenseManual tab
  3. Enter an amount and complete the expense (with merchant)
  4. Tap it and choose Submit or Categorize to move it to a workspace
  5. Select a workspace
  6. Expected: You should be navigated to the Confirmation page
  7. Tap the back button on the Confirmation page
  8. Expected: You should go back to the Participants page
  9. Select a P2P chat
  10. Expected: You should be navigated to the Confirmation page
  11. Clear the merchant and tap Save
  12. Tap the back button on the Confirmation page
  13. Expected: You should go back to the Participants page
  14. Select a workspace
  15. Expected: You should be navigated to the Merchant step

Test Case 9: Track Expense from Workspace Chat and FAB (Both)

Steps:

  1. Open a workspace expense chat
  2. Tap the + button in the composer
  3. Select Track expenseMap tab
  4. Select waypoints and tap Next
  5. Expected: You should be navigated to the Confirmation page

Test Case 10: Track Expense (Manual) from Workspace Chat and FAB (Both)

Steps:

  1. Open a workspace expense chat
  2. Tap the + button in the composer
  3. Select Track expenseManual tab
  4. Enter distance and tap Next
  5. Expected: You should be navigated to the Confirmation page

Precondition:

  • Workspace has per diem rates.
  1. Go to workspace chat.
  2. Create a per diem expense.
  3. Open the per diem expense.
  4. Go to self DM.
  5. Open the unreported per diem expense.
  6. Click Report > Remove from report/
  7. Click on the report header > Submit it to someone.
  8. Select any participant
  9. Verify that the merchant step isn't displayed
  1. Go to workspace chat.
  2. Create an empty report.
  3. Open the empty report.
  4. Click Add expense > Create expense > Manual.
  5. Enter amount > Next.
  6. Verify that the merchant page is displayed

Precondition:

  • User has received an invoice.
  1. Open FAB > Send invoice.
  2. Enter amount > Next.
  3. Enter merchant > Next.
  4. Select user.
  5. On confirm page, click Send invoice.
  6. On invoice room, click + > Send invoice.
  7. Enter amount > Next.
  8. Verify that the merchant step isn't displayed in both cases
  1. Go to self DM.
  2. Create a manual or map distance expense.
  3. Click Submit it to someone.
  4. Select workspace chat.
  5. Verify that the merchant step isn't displayed
  1. Go to self DM.
  2. Create a manual expense with merchant.
  3. Click Submit it to someone.
  4. Select workspace chat.
  5. Verify that the merchant step isn't displayed.

Precondition:

  • User has a workspace.
  1. Open FAB > Create expense > Manual.
  2. Enter amount > Next.
  3. Enter merchant > Next.
  4. On confirm page, click To field.
  5. Select a user (not self DM).
  6. Verify that the merchant step isn't displayed
  1. Go to workspace chat.
  2. Create an empty report.
  3. On the report preview, click Add expense > Create expense.
  4. Create a manual expense.
  5. Verify that the user stays on the workspace chat

Precondition:

  • Time tracking is enabled in the workspace.
  1. Go to workspace chat.
  2. Create a time expense.
  3. Open the time expense.
  4. Click Report > Remove from report.
  5. Go to self DM.
  6. Open the time expense.
  7. Click on the header > Submit it to someone.
  8. Enter email and select user.
  9. On confirm page, click Merchant.
  10. Clear the merchant and save it.
  11. Click RHP back button.
  12. Select workspace chat
  13. Verify that the merchant step is opened
  • Verify that no errors appear in the JS console

Offline tests

Same

QA Steps

Same as test

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

Android: Native
Screen.Recording.2025-12-03.at.15.27.09.mov
Android: mWeb Chrome
Screen.Recording.2025-12-03.at.15.26.38.mov
iOS: Native
Screen.Recording.2025-12-03.at.15.25.37.mov
iOS: mWeb Safari
Screen.Recording.2025-12-03.at.15.24.18.mov
MacOS: Chrome / Safari
Screen.Recording.2025-12-03.at.15.23.20.mov
Screen.Recording.2025-12-03.at.15.35.10.mov
Screen.Recording.2026-01-28.at.01.05.58.mov
Screen.Recording.2026-01-28.at.01.06.29.mov
Screen.Recording.2026-01-28.at.01.06.56.mov
Screen.Recording.2026-01-28.at.01.07.22.mov
Screen.Recording.2026-01-28.at.01.07.42.mov
Screen.Recording.2026-01-28.at.01.09.16.mov
Screen.Recording.2026-02-12.at.11.20.25.mov
Screen.Recording.2026-02-12.at.11.20.53.mov

… ask for merchant after asking for amount v2""
@codecov
Copy link

codecov bot commented Feb 12, 2026

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 Δ
...rc/pages/iou/request/step/IOURequestStepAmount.tsx 3.50% <0.00%> (-0.10%) ⬇️
.../pages/iou/request/step/IOURequestStepMerchant.tsx 0.00% <0.00%> (ø)
src/ROUTES.ts 12.80% <0.00%> (-0.06%) ⬇️
src/libs/IOUUtils.ts 73.86% <0.00%> (-3.52%) ⬇️
...es/iou/request/step/IOURequestStepParticipants.tsx 0.00% <0.00%> (ø)
... and 14 files with indirect coverage changes

@nkdengineer nkdengineer marked this pull request as ready for review February 12, 2026 04:30
@nkdengineer nkdengineer requested review from a team as code owners February 12, 2026 04:30
@melvin-bot melvin-bot bot requested a review from Krishna2323 February 12, 2026 04:30
@melvin-bot
Copy link

melvin-bot bot commented Feb 12, 2026

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

1 similar comment
@melvin-bot
Copy link

melvin-bot bot commented Feb 12, 2026

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

@melvin-bot melvin-bot bot requested review from heyjennahay and removed request for a team February 12, 2026 04:30
if (isEditing) {
return isPolicyExpenseChat(report) || isExpenseRequest(report);
}
return transaction?.participants?.some((participant) => !!participant.isPolicyExpenseChat);
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ PERF-6 (docs)

The useFocusEffect hook is resetting component state (isSaved and currentMerchant) based on props changing. This state can be derived directly from props instead of using an effect.

Suggested fix:
Remove the useFocusEffect and derive the state directly. The currentMerchant state can be initialized directly from initialMerchant without needing to reset it in an effect:

// Remove useFocusEffect - state will naturally reset when component remounts
// The currentMerchant state is already initialized from initialMerchant
const [currentMerchant, setCurrentMerchant] = useState(initialMerchant);

If you need to respond to prop changes, consider using the key prop pattern (see PERF-7) or compute values during render.


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


const navigateBack = useCallback(() => {
Navigation.goBack(backTo);
}, [backTo]);
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ PERF-6 (docs)

The navigation logic inside useEffect depends on multiple values (backTo, isEditing, backToReport) to determine where to navigate. This could be computed during the navigation action itself rather than in a useEffect that triggers after state changes.

Suggested fix:
Consider computing the navigation target at the point where setIsSaved(true) is called in the updateMerchant function, rather than relying on a useEffect to react to the isSaved state change:

const updateMerchant = (value: FormOnyxValues<typeof ONYXKEYS.FORMS.MONEY_REQUEST_MERCHANT_FORM>) => {
    const newMerchant = value.moneyRequestMerchant?.trim();
    
    // ... existing validation logic ...
    
    // Compute navigation target directly
    const shouldNavigateToConfirmation = !isEditing && !backTo;
    if (shouldNavigateToConfirmation) {
        Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(action, iouType, transactionID, reportID, backToReport, undefined, Navigation.getActiveRoute()));
    } else {
        Navigation.goBack(backTo);
    }
};

This eliminates the need for the isSaved state and the corresponding useEffect.


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

@@ -88,6 +89,7 @@ function IOURequestStepParticipants({

// We need to set selectedReportID if user has navigated back from confirmation page and navigates to confirmation page with already selected participant
const selectedReportID = useRef<string>(participants?.length === 1 ? (participants.at(0)?.reportID ?? reportID) : reportID);
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ CONSISTENCY-4 (docs)

The selectedParticipants ref is created but only used once at line 341 to read the first participant. This ref is redundant since the same value can be accessed directly from the participants variable or the function parameter val in addParticipant.

Suggested fix:
Remove the selectedParticipants ref and use the existing participants prop or the val parameter directly:

// Remove line 91:
// const selectedParticipants = useRef<Participant[]>(participants);

// Remove line 226:
// selectedParticipants.current = val;

// At line 341, use val or participants directly:
const firstParticipant = participants?.at(0); // or use _participants parameter if available

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

* @param isEditingSplitBill - Whether this is editing a split bill
* @returns true if merchant is required and missing, false otherwise
*/
function shouldRequireMerchant(transaction: OnyxInputOrEntry<Transaction> | undefined, report: OnyxInputOrEntry<Report> | undefined, isEditingSplitBill = false): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ CONSISTENCY-6 (docs)

The shouldRequireMerchant function accesses properties from potentially undefined objects (transaction?.participants, report) without comprehensive null checks. While the function returns false for undefined transactions, it could still throw errors if transaction.participants is malformed.

Suggested fix:
Add defensive checks to handle edge cases:

function shouldRequireMerchant(transaction: OnyxInputOrEntry<Transaction> | undefined, report: OnyxInputOrEntry<Report> | undefined, isEditingSplitBill = false): boolean {
    if (\!transaction) {
        return false;
    }

    if (\!isMerchantMissing(transaction)) {
        return false;
    }

    // For scan requests, merchant is not required unless it's a split bill being edited
    if (isScanRequest(transaction) && \!isEditingSplitBill) {
        return false;
    }

    // Add defensive check for participants array
    const hasParticipantsWithPolicyExpenseChat = Array.isArray(transaction?.participants) && 
        transaction.participants.some((participant) => \!\!participant?.isPolicyExpenseChat);

    // Check if merchant is required based on report type and participants
    return \!\!(isPolicyExpenseChatUtils(report) || isExpenseReport(report) || hasParticipantsWithPolicyExpenseChat);
}

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

if (!transactionID || !reportID) {
Log.warn('Invalid transactionID or reportID is used to build the MONEY_REQUEST_STEP_MERCHANT route');
}

Copy link
Contributor

Choose a reason for hiding this comment

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

❌ CONSISTENCY-2 (docs)

The route generation logic constructs query parameters and paths manually using string concatenation. While functional, this approach is error-prone and makes it harder to understand the relationship between reportActionID and backToReport parameters.

Suggested fix:
Add comments to clarify the parameter precedence and construction logic:

// Build optional route segments:
// 1. reportActionID is added as path segment (/:reportActionID)
// 2. backToReport is added as query parameter (?backToReport=...)
let optionalRoutePart = "";

if (reportActionID) {
    optionalRoutePart += `/${reportActionID}`;
}
if (backToReport) {
    optionalRoutePart += `?backToReport=${backToReport}`;
}

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

return;
}

const firstParticipant = selectedParticipants.current?.at(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ PERF-2 (docs)

The merchant requirement check is performed after several expensive operations including setting transaction report, split shares, and other transaction manipulations. This check could be moved earlier to avoid unnecessary work.

Suggested fix:
Move the merchant requirement check before the expensive transaction operations:

const goToNextStep = useCallback(
    (_value?: string, _participants?: Participant[]) => {
        const isCategorizing = action === CONST.IOU.ACTION.CATEGORIZE;
        const isShareAction = action === CONST.IOU.ACTION.SHARE;

        // Check merchant requirement early
        const firstParticipant = _participants?.at(0) || participants?.at(0);
        const isMerchantRequired =
            \!\!firstParticipant?.isPolicyExpenseChat &&
            isMerchantMissing(initialTransaction) &&
            (iouRequestType === CONST.IOU.REQUEST_TYPE.MANUAL || (isMovingTransactionFromTrackExpense && iouRequestType === CONST.IOU.REQUEST_TYPE.TIME));

        // ... rest of the logic
    },
    // ...
);

This avoids performing split share calculations and other operations when the user will immediately navigate to the merchant page.


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

Performance.markStart(CONST.TIMING.OPEN_CREATE_EXPENSE_APPROVE);
waitForKeyboardDismiss(() => {
// If the backTo parameter is set, we should navigate back to the confirmation screen that is already on the stack.
// We wrap navigation in setNavigationActionToMicrotaskQueue so that data loading in Onyx and navigation do not occur simultaneously, which resets the amount to 0.
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ CONSISTENCY-6 (docs)

The navigation logic has complex conditional branching with multiple paths (backTo with/without isMerchantRequired, merchant step with forceReplace, etc.) but lacks error handling or validation for edge cases. If the navigation fails or produces unexpected states, there's no fallback.

Suggested fix:
Add validation and comments to clarify the navigation logic:

// Navigation logic:
// 1. If merchant is required and backTo is set: go back first, then replace with merchant page
// 2. If merchant is required without backTo: navigate to merchant page with forceReplace
// 3. If merchant not required and backTo is set: go back to confirmation
// 4. Otherwise: navigate normally to confirmation or category page

if (backTo && !isMerchantRequired) {
    // We don't want to compare params because we just changed the participants.
    Navigation.goBack(route, {compareParams: false});
} else {
    // If the merchant step is required and the backTo parameter is set, we need to go back to the confirmation screen first
    if (isMerchantRequired && backTo) {
        Navigation.goBack();
    }
    Navigation.navigate(route, {forceReplace: isMerchantRequired && !!backTo});
}

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

setSplitShares(transaction, amountInSmallestCurrencyUnits, selectedCurrency || CONST.CURRENCY.USD, participantAccountIDs);
}
setMoneyRequestParticipantsFromReport(transactionID, report, currentUserPersonalDetails.accountID).then(() => {
// If merchant is required and missing, navigate to merchant step first
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ PERF-2 (docs)

The merchant requirement check at line 310 is performed AFTER calling setMoneyRequestParticipantsFromReport which is an expensive async operation. If merchant is required, the user immediately navigates away, making the confirmation page setup work unnecessary.

Suggested fix:
Check merchant requirement before the async operation:

// Check merchant requirement first to avoid unnecessary async work
if (shouldRequireMerchant(transaction, report, isEditingSplitBill)) {
    Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, reportID, undefined, reportActionID, backToReport));
    return;
}

setMoneyRequestParticipantsFromReport(transactionID, report, currentUserPersonalDetails.accountID).then(() => {
    navigateToConfirmationPage(iouType, transactionID, reportID, backToReport);
});

This avoids the async participant setup when it's not needed for the next screen.


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

setTransactionReport(transactionID, {reportID: transactionReportID}, true);
setMoneyRequestParticipantsFromReport(transactionID, targetReport, currentUserPersonalDetails.accountID).then(() => {
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouTypeTrackOrSubmit, transactionID, targetReport?.reportID));
if (transactionReportID === CONST.REPORT.UNREPORTED_REPORT_ID) {
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ PERF-2 (docs)

The merchant requirement check at line 333 could be performed BEFORE calling setMoneyRequestParticipantsFromReport to avoid unnecessary async work when navigating to the merchant step.

Suggested fix:
Restructure the logic to check merchant requirement first:

const resetToDefaultWorkspace = () => {
    setTransactionReport(transactionID, {reportID: transactionReportID}, true);
    
    // Check if we need merchant step before expensive participant setup
    if (transactionReportID !== CONST.REPORT.UNREPORTED_REPORT_ID) {
        Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, targetReport?.reportID, undefined, reportActionID));
        return;
    }
    
    setMoneyRequestParticipantsFromReport(transactionID, targetReport, currentUserPersonalDetails.accountID).then(() => {
        Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouTypeTrackOrSubmit, transactionID, targetReport?.reportID));
    });
};

This avoids the async participant operation when immediately navigating to the merchant step.


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

const chatReportID = selectedReport?.chatReportID ?? selectedReport?.reportID;

Navigation.setNavigationActionToMicrotaskQueue(() => {
if (shouldRequireMerchant(transaction, selectedReport, isEditingSplitBill)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ PERF-2 (docs)

The merchant requirement check at line 359 is performed AFTER calling setNavigationActionToMicrotaskQueue and setting up the confirmation route. If merchant is required, this setup work is wasted since navigation immediately changes direction.

Suggested fix:
Check merchant requirement before queuing navigation work:

if (shouldRequireMerchant(transaction, selectedReport, isEditingSplitBill)) {
    Navigation.setNavigationActionToMicrotaskQueue(() => {
        Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.CREATE, navigationIOUType, transactionID, chatReportID, undefined, reportActionID));
    });
    return;
}

Navigation.setNavigationActionToMicrotaskQueue(() => {
    Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, navigationIOUType, transactionID, chatReportID));
});

This avoids setting up navigation to the confirmation page when the merchant page is the actual target.


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

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ded42d973a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouTypeTrackOrSubmit, transactionID, targetReport?.reportID));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, targetReport?.reportID, undefined, reportActionID));

Choose a reason for hiding this comment

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

P2 Badge Gate default-workspace merchant redirect on requirement

This branch now always sends users to the merchant step whenever transactionReportID is not UNREPORTED, even though the transaction can already have a valid merchant (for example after returning from confirmation and being reset from a P2P selection due to a negative amount). In that case we should go straight back to confirmation, but this unconditional redirect reintroduces a redundant merchant step and inconsistent back navigation. Reuse shouldRequireMerchant(...) here before deciding the route.

Useful? React with 👍 / 👎.

@Krishna2323
Copy link
Contributor

Krishna2323 commented Feb 13, 2026

@nkdengineer could you please review the AI review comments? Thanks!

Okay, lets put this on hold for this discussion.

@Krishna2323
Copy link
Contributor

@nkdengineer please close this PR.

@nkdengineer nkdengineer closed this Mar 3, 2026
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.

2 participants