Skip to content

[Due for payment 2026-03-18] [$250] Expense - Modal remains open when select Duplicate expense #84237

Closed

Description

@jponikarchuk

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: v9.3.31-2
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #82005
Email or phone of affected tester (no customers): gocemate+b21549011@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Windows 10/Chrome
App Component: Other

Action Performed:

  1. Navigate to https://staging.new.expensify.com/ and log in
  2. Create expense to any user
  3. Open the expense> More> Duplicate expense

Expected Result:

Modal should close after selection

Actual Result:

Modal remains open

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022029421081061909391
  • Upwork Job ID: 2029421081061909391
  • Last Price Increase: 2026-03-05

Activity

  1. added
    Daily
    Bug
    on Mar 5, 2026
  2. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (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. MobileMage commented on Mar 5, 2026

    @MobileMage
    Contributor

    Proposal

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

    When a user opens an expense, taps "More", and selects "Duplicate expense", the dropdown menu stays open instead of closing after the action fires.

    What is the root cause of that problem?

    In MoneyRequestHeader.tsx, the shouldCloseModalOnSelect value for the DUPLICATE secondary action is set to true only when one of the blocking error conditions is active (distance expense unsupported, per diem on non-default workspace, or custom unit violation). In the normal flow where none of those conditions apply, the expression evaluates to false.

    ButtonWithDropdownMenu passes each menu item's shouldCloseModalOnSelect directly to the PopoverMenu. In ButtonWithDropdownMenu's onItemSelected callback the modal is only hidden when selectedSubitem.shouldCloseModalOnSelect !== false. Since the normal duplicate case produces shouldCloseModalOnSelect: false, the setIsMenuVisible(false) call is skipped and the menu stays open.

    shouldCloseModalOnSelect: isDistanceExpenseUnsupportedForDuplicating || hasCustomUnitOutOfPolicyViolation || isPerDiemRequestOnNonDefaultWorkspace,

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

    The fix is to change shouldCloseModalOnSelect on the DUPLICATE action to true unconditionally. The error-condition branches already return early before reaching the duplicateTransaction call, so there is no need to suppress modal close in the normal path. The same logic applies to MoneyReportHeader.tsx which has an identical pattern.

    shouldCloseModalOnSelect:
    isDistanceExpenseUnsupportedForDuplicating ||
    isPerDiemRequestOnNonDefaultWorkspace ||
    hasCustomUnitOutOfPolicyViolation ||

    // src/components/MoneyRequestHeader.tsx
    -            shouldCloseModalOnSelect: isDistanceExpenseUnsupportedForDuplicating || hasCustomUnitOutOfPolicyViolation || isPerDiemRequestOnNonDefaultWorkspace,
    +            shouldCloseModalOnSelect: true,
    
    // src/components/MoneyReportHeader.tsx
    -            shouldCloseModalOnSelect:
    -                isDistanceExpenseUnsupportedForDuplicating ||
    -                isPerDiemRequestOnNonDefaultWorkspace ||
    -                hasCustomUnitOutOfPolicyViolation ||
    +            shouldCloseModalOnSelect: true,

    The error-condition paths (showConfirmModal calls) return early without calling duplicateTransaction, so closing the dropdown in all paths is correct. The confirm modal that pops up for error states will still open normally after the dropdown closes.

    What alternative solutions did you explore? (Optional)

    N/A

  4. MelvinBot commented on Mar 5, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When a user opens an expense, taps "More" and selects "Duplicate expense", the popover/dropdown menu remains open instead of closing.

    What is the root cause of that problem?

    The shouldCloseModalOnSelect property on the DUPLICATE action is set to the boolean OR of error-condition flags:

    In MoneyRequestHeader.tsx:537:

    shouldCloseModalOnSelect: isDistanceExpenseUnsupportedForDuplicating || hasCustomUnitOutOfPolicyViolation || isPerDiemRequestOnNonDefaultWorkspace,
    

    In MoneyReportHeader.tsx:1540-1544:

    shouldCloseModalOnSelect:
        isDistanceExpenseUnsupportedForDuplicating ||
        isPerDiemRequestOnNonDefaultWorkspace ||
        hasCustomUnitOutOfPolicyViolation ||
        activePolicyExpenseChat?.iouReportID === moneyRequestReport?.reportID,
    

    For a normal expense (no error conditions), all flags are false, so shouldCloseModalOnSelect evaluates to false. This triggers a strict-equality check in PopoverMenu.selectItem() (PopoverMenu.tsx:324):

    } else if (selectedItem.shouldCloseModalOnSelect === false) {
        // Calls onSelected directly WITHOUT closing the modal
    

    Additionally, ButtonWithDropdownMenu (index.tsx:272) also skips closing:

    if (selectedSubitem.shouldCloseModalOnSelect !== false) {
        setIsMenuVisible(false);
    }
    

    So both closing mechanisms are bypassed when shouldCloseModalOnSelect is exactly false. Every other action in the same menu (Hold, Split, Merge, Delete, etc.) does not set shouldCloseModalOnSelect at all — it defaults to undefined, which does not match === false, so those actions properly close the modal via the shouldCallAfterModalHide branch.

    The intent of shouldCloseModalOnSelect was to keep the popover open when an error modal needs to display (e.g., unsupported distance expense). But because it's set to the OR of the error booleans, the normal (no-error) case gets false instead of undefined, and false === false triggers the no-close branch.

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

    Remove the shouldCloseModalOnSelect property from the DUPLICATE action in both MoneyRequestHeader.tsx and MoneyReportHeader.tsx.

    When no error conditions apply, the action should use the default closing behavior (like every other action). When error conditions DO apply, the onSelected handler already returns early after showing the error modal — since shouldCallAfterModalHide: true is injected by ButtonWithDropdownMenu, the onSelected callback runs after the popover closes, so the error modals will still display correctly.

    What alternative solutions did you explore? (Optional)

    An alternative would be to invert the logic so shouldCloseModalOnSelect is explicitly set to true in the normal case and false only when an error modal should be shown (e.g., shouldCloseModalOnSelect: !(isDistanceExpenseUnsupportedForDuplicating || ...)). However, removing the property entirely is simpler and consistent with how every other action in the menu works.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  5. added
    External
    on Mar 5, 2026
  6. added
    Help Wanted
    on Mar 5, 2026
  7. melvin-bot commented on Mar 5, 2026

    @melvin-bot

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

  8. changed the title [-]Expense - Modal remains open when select Duplicate expense[/-] [+][$250] Expense - Modal remains open when select Duplicate expense[/+] on Mar 5, 2026
  9. melvin-bot commented on Mar 5, 2026

    @melvin-bot
  10. marufsharifi commented on Mar 5, 2026

    @marufsharifi
    Contributor

    Proposal

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

    When a user selects Duplicate expense from the expense “More” menu, the dropdown remains open instead of closing.

    What is the root cause of that problem?

    shouldCloseModalOnSelect for the Duplicate action is set to a boolean OR of “error conditions.” In the normal (no-error) path that expression evaluates to false, which explicitly tells PopoverMenu and ButtonWithDropdownMenu not to close the menu. This differs from other actions where the property is omitted and default close behavior runs.

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

    Keep the intent of the flag (only keep the menu open when an error modal is shown), but invert the boolean so the default path closes the menu. This preserves the original purpose while fixing the normal flow.

    // src/components/MoneyRequestHeader.tsx
    -            shouldCloseModalOnSelect: isDistanceExpenseUnsupportedForDuplicating || hasCustomUnitOutOfPolicyViolation || isPerDiemRequestOnNonDefaultWorkspace,
    +            shouldCloseModalOnSelect: !(isDistanceExpenseUnsupportedForDuplicating || hasCustomUnitOutOfPolicyViolation || isPerDiemRequestOnNonDefaultWorkspace),
    
    // src/components/MoneyReportHeader.tsx
    -            shouldCloseModalOnSelect:
    -                isDistanceExpenseUnsupportedForDuplicating ||
    -                isPerDiemRequestOnNonDefaultWorkspace ||
    -                hasCustomUnitOutOfPolicyViolation ||
    -                activePolicyExpenseChat?.iouReportID === moneyRequestReport?.reportID,
    +            shouldCloseModalOnSelect: !(
    +                isDistanceExpenseUnsupportedForDuplicating ||
    +                isPerDiemRequestOnNonDefaultWorkspace ||
    +                hasCustomUnitOutOfPolicyViolation ||
    +                activePolicyExpenseChat?.iouReportID === moneyRequestReport?.reportID
    +            ),

    What alternative solutions did you explore? (Optional)

    1. Remove shouldCloseModalOnSelect entirely for Duplicate so it falls back to default close behavior (consistent with other actions).
    2. Set shouldCloseModalOnSelect: true unconditionally for Duplicate (simplest change, but less aligned with the original intent to keep the menu open for error cases).
  11. yyyhakuna commented on Mar 5, 2026

    @yyyhakuna

    Proposal

    Problem Analysis

    When duplicating an expense, the modal that opens for selecting the duplicate target remains open after selection, requiring manual closure. This breaks the expected UX flow.

    Root Cause: After expense duplication is selected and processed, the modal's onDismiss callback isn't being triggered or the modal state isn't being reset.

    Solution

    1. Find the duplicate expense modal component handler (likely in ExpenseDetailsModal or related component)
    2. After successful duplication action, trigger modal dismiss/close
    3. Verify modal state is properly reset in the action flow

    Implementation Approach

    • Locate the duplicate action handler
    • Add modal close trigger after duplication completes
    • Ensure state management properly reflects modal closure
    • Test on staging to confirm modal closes

    Expected Changes

    • 1-2 files modified (modal logic + action handler)
    • ~20-30 lines of code changes
    • No breaking changes to other components

    Awaiting assignment. Ready to start once assigned on Upwork.

  12. 24 remaining items

  13. melvin-bot commented on Mar 11, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.35-1 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 2026-03-18. 🎊

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

  14. melvin-bot commented on Mar 11, 2026

    @melvin-bot

    @parasharrajat @mallenexpensify 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. added
    Daily
    and removed
    Weekly
    on Mar 17, 2026
  16. mallenexpensify commented on Mar 17, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @parasharrajat due $250 via NewDot

    @parasharrajat plz complete the BZ checklist and tag me in a post once you have. Thx

  17. parasharrajat commented on Mar 18, 2026

    @parasharrajat
    Member

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [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: [Duplicate Expenses] Re-enable Distance Expense Support with fixes #82005 (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: Not needed

    • [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: https://github.com/Expensify/Expensify/issues/613559

    Regression Test Proposal

    Test:

    1. Navigate to the app and log in
    2. Create an expense to any user
    3. Open the expense and click "More"
    4. Select "Duplicate expense"
    5. Verify the button briefly shows "Duplicated ✓" and then the dropdown closes automatically
    6. Verify a duplicate expense was created

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-ae3b-a1ca-8ea6-05742884e0f4
  18. parasharrajat commented on Mar 18, 2026

    @parasharrajat
    Member
  19. melvin-bot commented on Mar 18, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2029421081061909391/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  20. mallenexpensify commented on Mar 18, 2026

    @mallenexpensify
    Contributor

    Thanks Rajat

  21. parasharrajat commented on Apr 20, 2026

    @parasharrajat
    Member

    Payment requested as per #84237 (comment)

  22. garrettmknight commented on Apr 23, 2026

    @garrettmknight
    Contributor

    $250 approved for @parasharrajat

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions