Skip to content

[Due for payment 2025-11-26] [$250] Expense - Revisiting create expense page from confirm details page changes the selected user #72593

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.2.30-1
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Action Performed:

Pre-condition: Have 2 workspaces

  1. Launch app
  2. Tap fab - create expense
  3. Enter an amount
  4. Tap next
  5. Tap To field and select another workspace
  6. Tap app back button
  7. Now note the To field

Expected Result:

Revisiting create expense page from confirm details page musnt change the selected user

Actual Result:

Revisiting create expense page from confirm details page changes the selected user

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop
Platforms Tested: On which of our officially supported platforms was this issue tested:
  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6974660_1760456928829.Screenrecorder-2025-10-14-21-12-06-251.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021978133655415606832
  • Upwork Job ID: 1978133655415606832
  • Last Price Increase: 2025-10-21
  • Automatic offers:
    • QichenZhu | Reviewer | 109220202
Issue OwnerCurrent Issue Owner: @nkuoch

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 14, 2025
  2. melvin-bot commented on Oct 14, 2025

    @melvin-bot

    Triggered auto assignment to @clarajones-expensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. changed the title [-]Expense - Revisiting create expense page from confirm details page changes the selected user[/-] [+][$250] Expense - Revisiting create expense page from confirm details page changes the selected user[/+] on Oct 14, 2025
  4. melvin-bot commented on Oct 14, 2025

    @melvin-bot
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 14, 2025
  6. melvin-bot commented on Oct 14, 2025

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @QichenZhu (External)

  7. ShridharGoel commented on Oct 14, 2025

    @ShridharGoel
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-10-14 18:17:18 UTC.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a user starts an expense in one workspace, switches the “To” field to a different workspace on the confirmation screen, and then goes back to the amount step to adjust the total, the confirmation screen does not show the earlier workspace selection.

    What is the root cause of that problem?

    The amount step always reapplies the default participants picked from the source report once the user leaves the screen. Even when participants already exist in the draft transaction, the code calls setMoneyRequestParticipantsFromReport, which overwrites the manually chosen workspace.

    isDraftPolicy: false,
    participantParams: {
    payeeEmail: currentUserPersonalDetails.login,
    payeeAccountID: currentUserPersonalDetails.accountID,
    participant: participants.at(0) ?? {},
    },
    transactionParams: {
    amount: backendAmount,
    currency: currency ?? 'USD',
    created: transaction?.created,
    merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT,
    },
    });
    return;
    }
    }
    if (isSplitBill && !report.isOwnPolicyExpenseChat && report.participants) {
    const participantAccountIDs = Object.keys(report.participants).map((accountID) => Number(accountID));
    setSplitShares(transaction, amountInSmallestCurrencyUnits, currency || CONST.CURRENCY.USD, participantAccountIDs);
    }
    setMoneyRequestParticipantsFromReport(transactionID, report).then(() => {
    navigateToConfirmationPage();
    });
    return;
    }
    // If there was no reportID, then that means the user started this flow from the global + menu
    // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense.
    if (
    iouType === CONST.IOU.TYPE.CREATE &&
    isPaidGroupPolicy(defaultExpensePolicy) &&
    defaultExpensePolicy?.isPolicyExpenseChatEnabled &&
    !shouldRestrictUserBillableActions(defaultExpensePolicy.id)
    ) {
    const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, defaultExpensePolicy?.id);
    const shouldAutoReport = !!defaultExpensePolicy?.autoReporting || !!personalPolicy?.autoReporting;
    const transactionReportID = shouldAutoReport ? activePolicyExpenseChat?.reportID : CONST.REPORT.UNREPORTED_REPORT_ID;
    setTransactionReport(transactionID, {reportID: transactionReportID}, true);
    setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat).then(() => {
    Navigation.navigate(
    ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
    CONST.IOU.ACTION.CREATE,
    iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType,
    transactionID,
    activePolicyExpenseChat?.reportID,
    ),
    );
    });
    } else {
    Navigation.setNavigationActionToMicrotaskQueue(() => {
    navigateToParticipantPage(iouType, transactionID, reportID);
    });
    }
    };
    const saveAmountAndCurrency = ({amount, paymentMethod}: AmountParams) => {
    const newAmount = convertToBackendAmount(Number.parseFloat(amount));
    // Edits to the amount from the splits page should reset the split shares.
    if (transaction?.splitShares) {
    resetSplitShares(transaction, newAmount, currency);
    }
    if (!isEditing) {
    navigateToNextPage({amount, paymentMethod});
    return;

    What changes do you think we should make in order to solve the problem?

    Track whether the draft transaction already has participants, and skip the auto-assignment path in that case. Reuse the existing participant list (and their reportID) when navigating forward so that the confirmation page keeps the workspace the user selected.

    const existingParticipants = useMemo(
        () => draftTransaction?.participants ?? transaction?.participants ?? [],
        [draftTransaction?.participants, transaction?.participants],
    );
    const hasExistingParticipants = existingParticipants.length > 0;
    const existingPolicyParticipant = existingParticipants.find((participant) => participant?.isPolicyExpenseChat);
    const existingParticipantReportID = existingPolicyParticipant?.reportID ?? existingParticipants.at(0)?.reportID;
    
    ...
    if (report?.reportID && !isReportArchived && iouType !== CONST.IOU.TYPE.CREATE) {
    ...
        if (hasExistingParticipants) {
            navigateToConfirmationPage();
            return;
        }
        setMoneyRequestParticipantsFromReport(transactionID, report).then(() => {
            navigateToConfirmationPage();
        });
    ...
    }
    
    if (
        iouType === CONST.IOU.TYPE.CREATE &&
        isPaidGroupPolicy(defaultExpensePolicy) &&
        defaultExpensePolicy?.isPolicyExpenseChatEnabled &&
        !shouldRestrictUserBillableActions(defaultExpensePolicy.id)
    ) {
    ...
    
        if (hasExistingParticipants) {
            const participantReportID = existingParticipantReportID ?? transaction?.reportID ?? activePolicyExpenseChat?.reportID ?? reportID;
            Navigation.navigate(
                ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
                    CONST.IOU.ACTION.CREATE,
                    iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType,
                    transactionID,
                    participantReportID,
                ),
            );
            return;
        }
    ...
    }
  8. QichenZhu commented on Oct 17, 2025

    @QichenZhu
    Contributor

    @ShridharGoel, thanks for your proposal, but it causes a regression: the amount resets to 0 the second time navigating back.

    Screen.Recording.2025-10-17.at.11.42.13.PM.mov
  9. ganzz4 commented on Oct 19, 2025

    @ganzz4
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When creating an expense from the FAB, if a user enters an amount, proceeds to select a different workspace in the "To" field, and then taps the back button to return to the amount page, the "To" field reverts to the default workspace instead of preserving the user's selection.

    What is the root cause of that problem?

    In IOURequestStepAmount.tsx, when the user navigates forward by tapping "Next", the navigateToNextPage function always calls setMoneyRequestParticipantsFromReport() to set the transaction participants based on the default workspace policy. This happens regardless of whether the user has already manually selected different participants through the participant selection flow.

    When navigating back from the confirmation page and tapping "Next" again, this code re-executes and overwrites the user's manual selection with the default workspace participants:

    // If there was no reportID, then that means the user started this flow from the global + menu
    // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense.
    if (
    iouType === CONST.IOU.TYPE.CREATE &&
    isPaidGroupPolicy(defaultExpensePolicy) &&
    defaultExpensePolicy?.isPolicyExpenseChatEnabled &&
    !shouldRestrictUserBillableActions(defaultExpensePolicy.id)
    ) {
    const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, defaultExpensePolicy?.id);
    const shouldAutoReport = !!defaultExpensePolicy?.autoReporting || !!personalPolicy?.autoReporting;
    const transactionReportID = shouldAutoReport ? activePolicyExpenseChat?.reportID : CONST.REPORT.UNREPORTED_REPORT_ID;
    setTransactionReport(transactionID, {reportID: transactionReportID}, true);
    setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat).then(() => {
    Navigation.navigate(
    ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
    CONST.IOU.ACTION.CREATE,
    iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType,
    transactionID,
    activePolicyExpenseChat?.reportID,
    ),
    );
    });

    What changes do you think we should make in order to solve the problem?

    Before calling setMoneyRequestParticipantsFromReport(), check if participants already exist in the transaction and whether they differ from the default workspace. If they do, preserve the user's selection instead of overwriting it:

    const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, defaultExpensePolicy?.id);
    const shouldAutoReport = !!defaultExpensePolicy?.autoReporting || !!personalPolicy?.autoReporting;
    const transactionReportID = shouldAutoReport ? activePolicyExpenseChat?.reportID : CONST.REPORT.UNREPORTED_REPORT_ID;
    
    // Keep manually selected participants if different from default workspace
    const hasExistingParticipants = transaction?.participants && transaction.participants.length > 0;
    const existingParticipantReportID = transaction?.participants?.at(0)?.reportID;
    const shouldKeepExistingParticipants = hasExistingParticipants && existingParticipantReportID !== activePolicyExpenseChat?.reportID;
    
    if (shouldKeepExistingParticipants) {
        // Navigate with existing participants, using Promise to ensure form state is saved
        Promise.resolve().then(() => {
            Navigation.navigate(
                ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
                    CONST.IOU.ACTION.CREATE,
                    iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType,
                    transactionID,
                    existingParticipantReportID,
                ),
            );
        });
    } else {
        // Set default workspace participants
        setTransactionReport(transactionID, {reportID: transactionReportID}, true);
        setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat).then(() => {
            Navigation.navigate(
                ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
                    CONST.IOU.ACTION.CREATE,
                    iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType,
                    transactionID,
                    activePolicyExpenseChat?.reportID,
                ),
            );
        });
    }

    const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, defaultExpensePolicy?.id);
    const shouldAutoReport = !!defaultExpensePolicy?.autoReporting || !!personalPolicy?.autoReporting;
    const transactionReportID = shouldAutoReport ? activePolicyExpenseChat?.reportID : CONST.REPORT.UNREPORTED_REPORT_ID;
    setTransactionReport(transactionID, {reportID: transactionReportID}, true);
    setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat).then(() => {
    Navigation.navigate(
    ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
    CONST.IOU.ACTION.CREATE,
    iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType,
    transactionID,
    activePolicyExpenseChat?.reportID,
    ),
    );
    });

    The Promise.resolve().then() in the if branch ensures consistent async timing with the else branch, allowing the form state to be properly saved before navigation occurs.

    Note: Similar patterns may exist in other request step files and should be reviewed for the same issue

    What alternative solutions did you explore? (Optional)

    Result:

    fix.mp4
  10. github-actions commented on Oct 19, 2025

    @github-actions
    Contributor

    ⚠️ @ganzz4 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  11. 49 remaining items

  12. melvin-bot commented on Nov 19, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  13. melvin-bot commented on Nov 19, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.60-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-11-26. 🎊

    For reference, here are some details about the assignees on this issue:

  14. melvin-bot commented on Nov 19, 2025

    @melvin-bot

    @QichenZhu The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  15. clarajones-expensify commented on Nov 19, 2025

    @clarajones-expensify
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment:

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal Template
    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    Test:

    Do we agree 👍 or 👎

  16. clarajones-expensify commented on Nov 19, 2025

    @clarajones-expensify
    Contributor

    Hi @QichenZhu ! would you fill out the above checklist when you can? thank you!

  17. QichenZhu commented on Nov 26, 2025

    @QichenZhu
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: I can't find an offending PR. It seems this case was not considered.

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A.

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    • Have 2 workspaces.

    Test:

    1. Launch the app.
    2. Tap FAB - Create expense - Manual.
    3. Enter an amount.
    4. Tap Next.
    5. Tap the To field and select a workspace other than the default workspace.
    6. Tap the back arrow.
    7. Verify the To field is the workspace you selected in step 5.

    Do we agree 👍 or 👎

  18. clarajones-expensify commented on Nov 26, 2025

    @clarajones-expensify
    Contributor

    Payment Summary

    Contributor: @ganzz4 paid $250 via Upwork
    Contributor+: @QichenZhu paid $250 via Upwork

  19. QichenZhu commented on Nov 26, 2025

    @QichenZhu
    Contributor

    Thanks @clarajones-expensify! Accepted the offer.

  20. melvin-bot commented on Nov 28, 2025

    @melvin-bot

    @nkuoch Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  21. melvin-bot commented on Dec 1, 2025

    @melvin-bot

    @nkuoch Eep! 4 days overdue now. Issues have feelings too...

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions