Skip to content

[Due for payment 2025-06-11] [$250] Expense - Error shows up after approving held expenses which are also duplicates #62423

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.1.47-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
Email or phone of affected tester (no customers): sjdoisjsdoddjs@gmail.com
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

  • Delayed submissions is set to Manually
  • Add approvals is enabled
  1. Go to staging.new.expensify.com
  2. Go to workspace chat
  3. Submit two expenses with the same amount
  4. Click on the expense preview to go to expense report
  5. Right click on any expense preview > Hold
  6. Enter reason and save it
  7. Click More > Submit
  8. Click More
  9. Click Approve

Expected Result:

There will be a confirmation modal to approve full amount or unheld amount

Actual Result:

There is no confirmation modal to approve full amount or unheld amount
Error shows up after approving held expenses which are also duplicates

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
Bug6837271_1747762362373.20250521_012811.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021925126785852858565
  • Upwork Job ID: 1925126785852858565
  • Last Price Increase: 2025-05-21
Issue OwnerCurrent Issue Owner: @laurenreidexpensify

Activity

  1. added
    Daily
    Bug
    on May 20, 2025
  2. melvin-bot commented on May 20, 2025

    @melvin-bot

    Triggered auto assignment to @laurenreidexpensify (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. ganzz4 commented on May 20, 2025

    @ganzz4
    Contributor

    Proposal

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

    When a user tries to approve an expense report that contains at least one held expense, a confirmation modal should appear, allowing the user to choose whether to approve only the unheld amount or the full amount.

    What is the root cause of that problem?

    The root cause is in the file src/components/MoneyReportHeader.tsx, inside the secondaryActionsImplementation object.
    Specifically, the Approve action in the secondary actions menu was directly calling approveMoneyRequest(moneyRequestReport), bypassing the logic in confirmApproval that checks for held expenses and shows the modal if needed.

    Problematic code:

    [CONST.REPORT.SECONDARY_ACTIONS.APPROVE]: {
    text: translate('iou.approve', getAmount(CONST.REPORT.SECONDARY_ACTIONS.APPROVE)),
    icon: Expensicons.ThumbsUp,
    value: CONST.REPORT.SECONDARY_ACTIONS.APPROVE,
    onSelected: () => {
    if (!moneyRequestReport) {
    return;
    }
    approveMoneyRequest(moneyRequestReport);
    },
    },

    As a result, the modal was only shown when using the primary Approve button, but not from the secondary actions menu.

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

    We should update the secondary actions menu so that the Approve action calls the same confirmApproval function as the primary Approve button.
    This ensures that the modal is always shown when there are held expenses, regardless of how the user initiates the approval.

    Solution code:

    [CONST.REPORT.SECONDARY_ACTIONS.APPROVE]: {
        text: translate('iou.approve', getAmount(CONST.REPORT.SECONDARY_ACTIONS.APPROVE)),
        icon: Expensicons.ThumbsUp,
        value: CONST.REPORT.SECONDARY_ACTIONS.APPROVE,
    
        // Use confirmApproval to ensure the hold confirmation modal is shown if there are held expenses.
        // This keeps the behavior consistent with the primary Approve button.
        onSelected: confirmApproval,
    },

    Now, the logic for showing the modal is unified and always works as expected.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    • Approving a report with at least one held expense via the primary Approve button should show the confirmation modal.
    • Approving a report with at least one held expense via the secondary actions menu should also show the confirmation modal.
    • Approving a report with no held expenses should not show the modal and should proceed directly.

    What alternative solutions did you explore? (Optional)

    • Adding a separate check inside approveMoneyRequest to show the modal if called directly.
      This was rejected because it would mix UI logic with business logic and could lead to duplicated code.
  4. ganzz4 commented on May 20, 2025

    @ganzz4
    Contributor

    I've recorded a quick demo video showing the fix in action:

    Result.mp4
  5. github-actions commented on May 20, 2025

    @github-actions
    Contributor

    ⚠️ @Tony-MK Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

  6. github-actions commented on May 20, 2025

    @github-actions
    Contributor

    ⚠️ @Tony-MK Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

  7. Tony-MK commented on May 20, 2025

    @Tony-MK
    Contributor

    Proposal

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

    Expense - Error shows up after approving held expenses, which are also duplicates

    What is the root cause of that problem?

    getSecondaryReportActions adds the approve action because the isApproveAction function does not check whether the report has violations to return false.

    if (isExpenseReport && isReportApprover && isProcessingReport && reportHasDuplicatedTransactions) {
    return true;
    }

    Unlike how canApprove checks for hasAnyViolations and doesn't allow the user to approve the report.

    const hasAnyViolations =
    hasMissingSmartscanFields(report.reportID, transactions) ||
    hasViolations(report.reportID, violations) ||
    hasNoticeTypeViolations(report.reportID, violations, true) ||
    hasWarningTypeViolations(report.reportID, violations, true);

    return isExpense && isApprover && isProcessing && isApprovalEnabled && !hasAnyViolations && reportTransactions.length > 0 && isCurrentUserManager;

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

    Other than checking for reportHasDuplicatedTransactions, we can return false early when the report has violations or add an extra to this condition in isApproveAction.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Create test cases for getSecondaryReportActions where the report has violations.

    What alternative solutions did you explore? (Optional)

    N/A

  8. thelullabyy commented on May 21, 2025

    @thelullabyy
    Contributor

    Proposal

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

    There is no confirmation modal to approve full amount or unheld amount
    Error shows up after approving held expenses which are also duplicates

    What is the root cause of that problem?

    The reason the API returns the error is the full parameter is undefined, we called approveMoneyRequest without full param and this function has no default value for this param

    approveMoneyRequest(moneyRequestReport);

    function approveMoneyRequest(expenseReport: OnyxEntry<OnyxTypes.Report>, full?: boolean) {

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

    1. We should call confirmApproval to display the confirm modal in the case has hold transactions.

    approveMoneyRequest(moneyRequestReport);

    1. To prevent this API from failing in the future, we should add the default value as true for full param

    function approveMoneyRequest(expenseReport: OnyxEntry<OnyxTypes.Report>, full?: boolean) {

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    NA

    What alternative solutions did you explore? (Optional)

    NA

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  9. added
    External
    on May 21, 2025
  10. changed the title [-]Expense - Error shows up after approving held expenses which are also duplicates[/-] [+][$250] Expense - Error shows up after approving held expenses which are also duplicates[/+] on May 21, 2025
  11. melvin-bot commented on May 21, 2025

    @melvin-bot
  12. added
    Help Wanted
    on May 21, 2025
  13. 30 remaining items

  14. removed
    Reviewing
    on Jun 4, 2025
  15. melvin-bot commented on Jun 4, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.58-4 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-06-11. 🎊

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

    • @ishpaul777 requires payment through NewDot Manual Requests
    • @ganzz4 requires payment (Needs manual offer from BZ)
  16. melvin-bot commented on Jun 4, 2025

    @melvin-bot

    @ishpaul777 @laurenreidexpensify @ishpaul777 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]

  17. laurenreidexpensify commented on Jun 9, 2025

    @laurenreidexpensify
    Contributor

    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:

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

  18. laurenreidexpensify commented on Jun 9, 2025

    @laurenreidexpensify
    Contributor

    @ishpaul777 bump for checklist before payment thanks

  19. added
    Daily
    and removed
    Weekly
    on Jun 11, 2025
  20. melvin-bot commented on Jun 11, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    • Reviewer: @ishpaul777 owed $250 via NewDot
    • ROLE: @ganzz4 paid $(AMOUNT) via Upwork (LINK)

    BugZero Checklist (@laurenreidexpensify)

    • 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/1925126785852858565/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  21. laurenreidexpensify commented on Jun 11, 2025

    @laurenreidexpensify
    Contributor

    @ishpaul777 pls complete checklist thanks

  22. ishpaul777 commented on Jun 11, 2025

    @ishpaul777
    Contributor

    will do in couple hours

  23. ishpaul777 commented on Jun 11, 2025

    @ishpaul777
    Contributor

    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:

    • [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: No need this came from a large new feature PR case might not be considered then

    • [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.- No need this part [Simplified actions] project we'd have enough tests covering the flow

  24. laurenreidexpensify commented on Jun 12, 2025

    @laurenreidexpensify
    Contributor

    Payment Summary:

  25. garrettmknight commented on Jul 3, 2025

    @garrettmknight
    Contributor

    $250 approved for @ishpaul777

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