Skip to content

[$250] Report - LHN and copied message show positive amount on negative expenses on member´s side #77178

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.74-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: #75934
Email or phone of affected tester (no customers): ibellicotest+2186@gmail.com
Issue reported by: Applause - Internal Team

Action Performed:

Prerequisite: Have two accounts opened on two different devices or environments
Prerequisite 2: User A has at least one workspace

  1. Open the staging.new.expensify.com website
  2. Open any workspace chat
  3. Click on the chat header and select Members
  4. Invite User B as a member
  5. Switch to User B's account
  6. Open the same workspace chat
  7. Switch back to User A's account
  8. Create three manual expenses with negative amount in the workspace chat
  9. Switch again to User B's account
  10. Note that the LHN subtitle displays the "-workspaceName- owes -amount-" as the last message but it is shown with positive amount
  11. Reopen chat and right-click on the placeholder and click "Copy message"
  12. Paste the message on the composer
    13.Note that the copied message is in the format: "-workspaceName- owes -amount-" but it is also shown with positive amount
  13. Open report and return to chat
  14. Right click on preview, and select "Copy Message" again
  15. Paste the message on composer
  16. Note that now, amount is correctly displayed as negative
  17. Note that amount in LHN is also correctly displayed now

Expected Result:

When admin creates expenses with negative amount, preview on LHN and message copied from report preview, should be displayed as negative on member´s side too

Actual Result:

When adming creates expenses with negative amount, preview on LHN and message copied from report preview, are shown with positive amount on member´s side
Preview and message copied, show correct amount after report is opened for the first time. (Steps 20 and 23 from PR are failing)

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
Bug7025138_1765300102982.Negative.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022001206540815244657
  • Upwork Job ID: 2001206540815244657
  • Last Price Increase: 2026-01-21
Issue OwnerCurrent Issue Owner: @shubham1206agra

Activity

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

    @melvin-bot

    Triggered auto assignment to @greg-schroeder (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. SAYAN02-DEV commented on Dec 9, 2025

    @SAYAN02-DEV

    Proposal

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

    When an admin creates expenses with negative amounts in a workspace chat, the LHN (Left Hand Navigation) subtitle and copied message display the amount as positive on the member's side until they open the report for the first time. After opening the report, the amounts correctly display as negative.

    What is the root cause of that problem?

    When displaying preview BEFORE report is loaded

    1. The amount is correctly stored as negative in the originalMessage

      App/src/libs/ReportUtils.ts

      Lines 5325 to 5327 in 4f4b76a

      const lastActorID = iouReportAction?.actorAccountID;
      let amount = originalMessage?.amount;
      let currency = originalMessage?.currency ? originalMessage?.currency : report.currency;
    2. The code retrieves the negative amount from originalMessage
    3. Then applies Math.abs() which strips the negative sign

      App/src/libs/ReportUtils.ts

      Lines 5343 to 5346 in 4f4b76a

      // if we have the amount in the originalMessage and lastActorID, we can use that to display the preview message for the latest expense
      if (amount !== undefined && lastActorID && !isPreviewMessageForParentChatReport) {
      const amountToDisplay = convertToDisplayString(Math.abs(amount), currency);

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

    To fix this issue we have to REMOVE the Math.abs() at line 5345

    App/src/libs/ReportUtils.ts

    Lines 5343 to 5346 in 4f4b76a

    // if we have the amount in the originalMessage and lastActorID, we can use that to display the preview message for the latest expense
    if (amount !== undefined && lastActorID && !isPreviewMessageForParentChatReport) {
    const amountToDisplay = convertToDisplayString(Math.abs(amount), currency);

    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?

    N/A

  4. yuwenmemon commented on Dec 10, 2025

    @yuwenmemon
    Contributor

    cc @rayane-d this is coming from #75934

  5. rayane-d commented on Dec 10, 2025

    @rayane-d
    Contributor

    It appears that this bug wasn't introduced by my PR. It's reproducible in production and was discovered while testing my PR on staging

  6. deleted a comment from melvin-bot on Dec 17, 2025
  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Dec 17, 2025
  8. changed the title [-]Report - LHN and copied message show positive amount on negative expenses on member´s side[/-] [+][$250] Report - LHN and copied message show positive amount on negative expenses on member´s side[/+] on Dec 17, 2025
  9. melvin-bot commented on Dec 17, 2025

    @melvin-bot
  10. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 17, 2025
  11. greg-schroeder commented on Dec 17, 2025

    @greg-schroeder
    Contributor

    Okay sending through to External as it's not a regression

  12. 26 remaining items

  13. NJ-2020 commented on Jan 8, 2026

    @NJ-2020
    Contributor

    Hi 👋 After looking into this one more deeply, at the first glance it seems a BE issue, but we navigate to another chat and then come back to trigger the OpenReport API call, the BE returns the report expense (transactions), but it didn't return expense report, so this check condition will return true and will display reportActionMessage instead of originalReportAction?.childReportName since the current report action has 3 child money request

    App/src/libs/ReportUtils.ts

    Lines 5066 to 5073 in a0bb986

    if (isEmptyObject(report) || !report?.reportID) {
    // This iouReport may be unavailable for one of the following reasons:
    // 1. After SignIn, the OpenApp API won't return iouReports if they're settled.
    // 2. The iouReport exists in local storage but hasn't been loaded into the allReports. It will be loaded automatically when the user opens the iouReport.
    // Until we know how to solve this the best, we just display the report action message.
    // If the report is empty, we display the report name to avoid showing "payer owes 0"
    return !!originalReportAction?.childReportName && originalReportAction?.childMoneyRequestCount === 0 ? originalReportAction?.childReportName : reportActionMessage;
    }

    Screen.Recording.2026-01-08.at.16.11.24.mp4

    But it seems after this [issue/PR], the expected behaviour is to return the current report name whenever if the action is report preview, so in this case it will be: Expense Report 2026-01-08

    Screen.Recording.2026-01-08.at.16.20.57.mov

    But it seems it doesn't work properly for unloaded report because of this check condition

    App/src/libs/ReportUtils.ts

    Lines 5062 to 5064 in a0bb986

    if (isCopyAction && report) {
    return computeReportName(report) || (originalReportAction?.childReportName ?? '');
    }

    Screen.Recording.2026-01-08.at.16.28.55.mov

    We only check if the copyAction is true & the report has been loaded/exists, but in this case it will return false, i think it being caused by this commit accidentally.

    I think we should update the code to:

    if (isCopyAction) {
        return report ? computeReportName(report) : originalReportAction?.childReportName ?? '';
    }

    Thanks.

  14. mavrickdeveloper commented on Jan 8, 2026

    @mavrickdeveloper
    Contributor

    @NJ-2020 I think we might be looking at different problems here. The issue title specifically says "show positive amount on negative expenses" , it's fundamentally about the amount value being wrong, not about which string/report name gets returned.
    Your fix at lines 5062-5064 would return childReportName ("Expense Report 2026-01-08") instead of the amount-containing message - but that's SIDE-STEPPING the problem rather than fixing it. if you look at line 5240 vs line 5255 in the same function - there's already an internal inconsistency. When linkedTransaction is available, getTransactionAmount(linkedTransaction, isExpenseReport(report)) handles signs correctly based on report type. But when it falls back to originalMessage.amount, it unconditionally applies Math.abs(). That's the actual bug ,the fallback path doesn't match the primary path's sign-aware logic.

    i believe my proposal addresses the root issue: #77178 (comment)

  15. melvin-bot commented on Jan 9, 2026

    @melvin-bot

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

  16. melvin-bot commented on Jan 13, 2026

    @melvin-bot

    @shubham1206agra 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  17. greg-schroeder commented on Jan 14, 2026

    @greg-schroeder
    Contributor

    Thoughts on the above @shubham1206agra?

  18. shubham1206agra commented on Jan 14, 2026

    @shubham1206agra
    Contributor

    Ok, I investigated this further, and it seems like @NJ-2020 is correct here. The behaviour is correct, but BE uses bracket notation to show a negative expense, which is why the expense appears positive, but it is actually negative.

    @greg-schroeder, can you close this issue, as I don't think we will prioritise fixing this behaviour for now?

  19. melvin-bot commented on Jan 19, 2026

    @melvin-bot

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

  20. melvin-bot commented on Jan 21, 2026

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  21. melvin-bot commented on Jan 24, 2026

    @melvin-bot

    @shubham1206agra Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions