Skip to content

[Due for payment 2025-11-03] [$250] Expense - LHN shows "Pending..." as distance rate after rejecting the distance expense #72571

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: 9.2.30-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #62787
Email or phone of affected tester (no customers): josdnijoijsdojsoj@gmail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.5 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Delayed submissions are disabled in Workflows settings.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create a distance expense in workspace chat.
  4. Open the expense report.
  5. Click Submit.
  6. Click More > Reject.
  7. Enter reason and click Reject expense.

Expected Result:

LHN will show the distance rate after rejecting the distance expense.

Actual Result:

LHN shows "Pending..." as distance rate after rejecting the distance expense.
It only shows the rate after opening the expense thread.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021978302252049562990
  • Upwork Job ID: 1978302252049562990
  • Last Price Increase: 2025-10-15
  • Automatic offers:
    • situchan | Reviewer | 109134291
    • apeyada | Contributor | 109134293
Issue OwnerCurrent Issue Owner: @VictoriaExpensify

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 @VictoriaExpensify (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. Tony-MK commented on Oct 14, 2025

    @Tony-MK
    Contributor

    Proposal

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

    Expense - LHN shows "Pending..." as distance rate after rejecting the distance expense

    What is the root cause of that problem?

    When a report is rejected, we delete the report. However, we need policyID to get the transaction rate.

    The condition below, from getMerchant, will be true because the rate is null and policy. So iou.fieldPending is returned by getDistanceMerchant(). In turn, getMerchant() returns iou.fieldPending and the transaction name will end with "Pending...".

    const mileageRate = DistanceRequestUtils.getRate({transaction, policy});
    const {unit, rate} = mileageRate;
    const distanceInMeters = getDistanceInMeters(transaction, unit);
    if (!isUnreportedAndHasInvalidDistanceRateTransaction(transaction, policy)) {
    return DistanceRequestUtils.getDistanceMerchant(true, distanceInMeters, unit, rate, transaction.currency, translateLocal, (digit) =>
    toLocaleDigit(IntlStore.getCurrentLocale(), digit),
    );

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

    Consider fixing rejectMoneyRequest() so getMerchant can find the policyID by setting the transaction's reportID to the self-dm or the rejectedReportID.

    What alternative solutions did you explore? (Optional)

    Alternative 1

    Instead of deleting the transaction report, we can remove reportID or any other attribute to make the report inactive. So we can link the transaction to the report and, in turn, to the policy.

    Alternative 2

    Return a default mileage rate from the personal policy, since getDefaultMileageRate will return undefined when policy is none, and the transaction's rate field is not pending.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 15, 2025
  5. changed the title [-]Expense - LHN shows "Pending..." as distance rate after rejecting the distance expense[/-] [+][$250] Expense - LHN shows "Pending..." as distance rate after rejecting the distance expense[/+] on Oct 15, 2025
  6. melvin-bot commented on Oct 15, 2025

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

    @melvin-bot

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

  9. apeyada commented on Oct 15, 2025

    @apeyada
    Contributor

    Proposal

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

    LHN shows "Pending..." as distance rate after rejecting the distance expense

    What is the root cause of that problem?

    We show xxx for merchant in LHN. Here's merchant getting logic:

    const policy = policyParam ?? getPolicy(report?.policyID);
    const mileageRate = DistanceRequestUtils.getRate({transaction, policy});
    const {unit, rate} = mileageRate;
    const distanceInMeters = getDistanceInMeters(transaction, unit);
    if (!isUnreportedAndHasInvalidDistanceRateTransaction(transaction, policy)) {
    return DistanceRequestUtils.getDistanceMerchant(true, distanceInMeters, unit, rate, transaction.currency, translateLocal, (digit) =>
    toLocaleDigit(IntlStore.getCurrentLocale(), digit),
    );
    }
    }
    return transaction?.modifiedMerchant ? transaction.modifiedMerchant : (transaction?.merchant ?? '');

    When reject distance expense, we delete report but we don't unlink that report from transaction, so transaction.reportID still remains.
    So

    if (!isUnreportedAndHasInvalidDistanceRateTransaction(transaction, policy)) {
    condition is met.

    Finally calls DistanceRequestUtils.getDistanceMerchant which returns Pending....

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

    When delete report, unlink that report from transaction optimistically by setting transaction.reportID to null or UNREPORTED_REPORT_ID (aka. "0").

                    {
                        onyxMethod: Onyx.METHOD.MERGE,
                        key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
                        value: {
                            reportID: "0",
                        },
                    },
    

    Here's the right place to add:

    App/src/libs/actions/IOU.ts

    Lines 12642 to 12647 in e95b3e6

    // For reports with single expense: Delete the report
    optimisticData.push({
    onyxMethod: Onyx.METHOD.SET,
    key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
    value: null,
    });

    We can also add successData and failureData.

    What alternative solutions did you explore? (Optional)

    if (!isUnreportedAndHasInvalidDistanceRateTransaction(transaction, policy)) {

    Add policy && condition here

  10. github-actions commented on Oct 15, 2025

    @github-actions
    Contributor

    ⚠️ @apeyada 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).

  11. situchan commented on Oct 15, 2025

    @situchan
    Contributor
    Screen.Recording.2025-10-15.at.8.42.38.PM.mov

    I noticed that reportID of transaction changes to "0" only after opening the rejected expense report from LHN.

  12. situchan commented on Oct 15, 2025

    @situchan
    Contributor

    @apeyada's proposal looks good to me.
    🎀 👀 🎀 C+ reviewed

  13. 14 remaining items

  14. changed the title [-][$250] Expense - LHN shows "Pending..." as distance rate after rejecting the distance expense[/-] [+][Due for payment 2025-11-03] [$250] Expense - LHN shows "Pending..." as distance rate after rejecting the distance expense[/+] on Oct 27, 2025
  15. melvin-bot commented on Oct 27, 2025

    @melvin-bot

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

  16. melvin-bot commented on Oct 27, 2025

    @melvin-bot

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

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

  17. melvin-bot commented on Oct 27, 2025

    @melvin-bot

    @situchan @VictoriaExpensify 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]

  18. situchan commented on Nov 3, 2025

    @situchan
    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: https://github.com/Expensify/App/pull/62787/files#r2485264559

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

    Delayed submissions are disabled in Workflows settings.

    Test:

    1. Go to workspace chat.
    2. Create a distance expense in workspace chat.
    3. Open the expense report.
    4. Click Submit.
    5. Click More > Reject.
    6. Enter reason and click Reject expense.
    7. Verify that expense report in LHN shows the distance rate after rejecting the distance expense.

    Do we agree 👍 or 👎

  19. VictoriaExpensify commented on Nov 3, 2025

    @VictoriaExpensify
    Contributor

    Issue raised to have regression test added to BrowserStack https://github.com/Expensify/Expensify/issues/564205

  20. VictoriaExpensify commented on Nov 3, 2025

    @VictoriaExpensify
    Contributor

    Payment summary:
    C: @apeyada - Offer has been sent to you through UW - please accept so I can make payment
    C+: @situchan - Paid $250 via Upwork

  21. VictoriaExpensify commented on Nov 6, 2025

    @VictoriaExpensify
    Contributor

    Updated Payment summary:
    C: @apeyada - Paid $250 via Upwork
    C+: @situchan - Paid $250 via Upwork

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