Skip to content

[Due for payment 2025-06-02] [$250] Expense - Unreported expense added to report in offline mode shows negative amount #62367

Closed

Description

@mitarachim

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

Action Performed:

Precondition:

  • Log in with Expensifail account.
  • Account has self DM and a workspace.
  1. Go to staging.new.expensify.com
  2. Go offline.
  3. Go to self DM.
  4. Track a manual expense in self DM.
  5. Go to workspace chat.
  6. Submit an expense.
  7. Click on the expense preview.
  8. Click More.
  9. Click Add expense > Add unreported expense.
  10. Select the track expense from Step 4.
  11. Click Add to report.

Expected Result:

The unreported expense added to report will not have negative amount.

Actual Result:

The unreported expense added to report in offline mode shows negative amount.

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

Bug6836997_1747741258608.20250520_193723.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021924853151837626596
  • Upwork Job ID: 1924853151837626596
  • Last Price Increase: 2025-05-20
  • Automatic offers:
    • nkdengineer | Contributor | 107383494
Issue OwnerCurrent Issue Owner: @twisterdotcom

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on May 20, 2025
  2. melvin-bot commented on May 20, 2025

    @melvin-bot

    Triggered auto assignment to @JS00001 (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  3. melvin-bot commented on May 20, 2025

    @melvin-bot

    Triggered auto assignment to @twisterdotcom (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.

  4. melvin-bot commented on May 20, 2025

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on May 20, 2025

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. nabi-ebrahimi commented on May 20, 2025

    @nabi-ebrahimi

    Proposal

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

    When a user adds an unreported expense to a report while offline, the expense displays a negative amount. This is confusing and incorrect because the amount should remain positive until the report is properly synced.


    What is the root cause of that problem?

    The getAmount function applies a negation (-amount) to values when isFromExpenseReport is true. However, it doesn't account for offline mode. In offline mode, unreported expenses are shown in a report context before they are properly associated with a reportID, leading to incorrect application of the report logic and display of a negative amount. here


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

    We should update the getAmount function to accept an isOffline flag and treat offline transactions similarly to unreported or IOU transactions. Specifically:

    • If isOffline is true, return the absolute value of the amount, avoiding the negation logic that applies only to fully reported expenses.
    function getAmount(
        transaction: OnyxInputOrEntry<Transaction>,
        isFromExpenseReport = false,
        isFromTrackedExpense = false,
        isOffline = false
    ): number {
        if (!isFromExpenseReport || isFromTrackedExpense || isOffline) {
            const amount = transaction?.modifiedAmount ?? 0;
            if (amount) {
                return Math.abs(amount);
            }
            return Math.abs(transaction?.amount ?? 0);
        }
    
        let amount = transaction?.modifiedAmount ?? 0;
        if (amount) {
            return -amount;
        }
    
        amount = transaction?.amount ?? 0;
        return amount ? -amount : 0;
    }
    

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

    N / A

    What alternative solutions did you explore? (Optional)

    Screen.Recording.2025-05-20.at.5.29.46.PM.mov
  7. JS00001 commented on May 20, 2025

    @JS00001
    Contributor

    @nabi-ebrahimi Since this is a deploy blocker & a regression that is on staging but not prod, I dont think we should be modifying a common method that hasn't been touched. Lets try and find the PR that caused this regression & go from there

    Unless its a new issue because of a new feature using this method?

  8. 34 remaining items

  9. melvin-bot commented on May 26, 2025

    @melvin-bot

    @JS00001 @twisterdotcom @nkdengineer 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]

  10. akinwale commented on Jun 2, 2025

    @akinwale
    Contributor

    @twisterdotcom Could you assign me as the C+ since I reviewed the PR? Thanks.

  11. akinwale commented on Jun 2, 2025

    @akinwale
    Contributor

    BugZero Checklist:

    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:
    • [@akinwale] 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: Fix adding unreported expense when expense is created in offline mode #62097 (comment)

    • [@akinwale] 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

    • [@akinwale] 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:

    • The account has an existing self-DM

    Test:

    1. Launch Expensify
    2. Go offline
    3. Create a tracked expense (in the self-DM)
    4. Navigate to a workspace chat
    5. Create a new expense
    6. Open the expense report
    7. Click More > Add expense and select Add unreported expense
    8. Select the tracked expense created in step 3
    9. Verify that the amount for the expense in the report is not a negative amount.

    Do we agree 👍 or 👎?

  12. twisterdotcom commented on Jun 3, 2025

    @twisterdotcom
    Contributor

    Payment Summary:

  13. akinwale commented on Jun 3, 2025

    @akinwale
    Contributor

    @twisterdotcom One more payment due for @nabi-ebrahimi based on this comment.

  14. nabi-ebrahimi commented on Jun 3, 2025

    @nabi-ebrahimi

    Payment Summary:

    @twisterdotcom I couldn't find you on Slack. This is my Upwork profile, btw.

    https://www.upwork.com/freelancers/~01c641ee7bc16be868

  15. twisterdotcom commented on Jun 5, 2025

    @twisterdotcom
    Contributor

    Amazing, offer is here: https://www.upwork.com/nx/wm/offer/107573407. Closing again now as I updated the payment summary.

  16. nabi-ebrahimi commented on Jun 5, 2025

    @nabi-ebrahimi

    @twisterdotcom Thanks, I accepted the Offer

  17. JmillsExpensify commented on Jun 9, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @akinwale

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