Skip to content

[$250] Expense - Unreported per diem expense cannot be added to report. #83712

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.27-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-7031/folder/13176674/41237177/1218506828
Email or phone of affected tester (no customers): dreamnitethedragon@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Redminote 10S Android 13
App Component: Money Requests

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Create workpace and enable per diem ( import per diem rate)
  3. Open workspace chat
  4. Create a per diem expense
  5. Open the expense - report
  6. Remove the report
  7. Tap add expense - Unreported expense
  8. Select per diem expense
  9. Tap add to report

Expected Result:

Unreported per diem expense must be able to add to report.

Actual Result:

Unreported per diem expense cannot be added to report.

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

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022027419145795844269
  • Upwork Job ID: 2027419145795844269
  • Last Price Increase: 2026-02-27
Issue OwnerCurrent Issue Owner: @parasharrajat

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 27, 2026
  2. melvin-bot commented on Feb 27, 2026

    @melvin-bot

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

  3. melvin-bot commented on Feb 27, 2026

    @melvin-bot

    Triggered auto assignment to @heyjennahay (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 Feb 27, 2026

    @melvin-bot

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

  5. github-actions commented on Feb 27, 2026

    @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. OSBotify commented on Feb 27, 2026

    @OSBotify
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #81446 - "Fix - Make it more apparent in the expense chat carousel view when expenses are added to a report" by @FitseTLT (Medium confidence)
    Related Issues: None found

    Recommendation: REVERT

    PR #81446 introduced changes to highlight new expenses when added to reports. While the primary changes were to the UI highlighting logic, it modified the useNewTransactions hook by adding prevTransactions to the dependency array and introduced useIsFocused checks. These changes may be causing unintended side effects or race conditions that break the "add to report" functionality specifically for per diem expenses.

    Reasoning:

    Labels: Keep DeployBlockerCash (App deploy is blocked - this is a frontend bug requiring an App PR fix)

    📋 Detailed Analysis

    Evidence

    PR #81446 modified:

    1. src/hooks/useNewTransactions.ts - Added prevTransactions to dependency array (was previously excluded with eslint-disable)
    2. src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx - Added useIsFocused and useNewTransactions hooks
    3. Multiple preview components to support highlighting new transactions

    The bug occurs when:

    1. A per diem expense is created
    2. The expense is removed from its report (becomes unreported)
    3. User attempts to add the unreported per diem expense to a report
    4. The add operation fails

    Verification

    Root Cause

    The changes to useNewTransactions hook and the introduction of useIsFocused checks may be causing:

    • Race conditions in transaction state updates
    • Incorrect transaction filtering or identification
    • Focus-related side effects that interfere with the InteractionManager callbacks used in the add-to-report flow

    The per diem-specific nature suggests the issue may relate to how the highlighting logic interacts with per diem custom unit checks in AddUnreportedExpense.tsx (lines 91-96).

  7. OSBotify commented on Feb 27, 2026

    @OSBotify
    Contributor

    Additional Context

    Relevant File Paths:

    • /home/runner/_work/App/App/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx - Modified to add highlighting logic
    • /home/runner/_work/App/App/src/hooks/useNewTransactions.ts - Dependency array changed
    • /home/runner/_work/App/App/src/components/AddUnreportedExpenseFooter.tsx - Contains the add-to-report confirmation logic
    • /home/runner/_work/App/App/src/pages/AddUnreportedExpense.tsx - Contains per diem filtering logic (lines 91-96)

    Next Steps:

    1. Revert PR Fix - Make it more apparent in the expense chat carousel view when expenses are added to a report #81446
    2. Investigate the root cause of why the highlighting changes break per diem add-to-report functionality
    3. Create a new PR with a fix that addresses both the highlighting feature and preserves per diem add-to-report functionality

    @FitseTLT @situchan - As the author and reviewer of PR #81446, please review this analysis.

  8. MelvinBot commented on Feb 27, 2026

    @MelvinBot
    Contributor

    Proposal

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

    After removing a per diem expense from a report (making it unreported), the user cannot re-add it to a report via the "Add expense" → "Unreported expense" flow. This is reproducible in staging (V9.3.27-0) but not in production.

    What is the root cause of that problem?

    PR #81742 (merged Feb 26) introduced a key format mismatch in AddUnreportedExpenseFooter.tsx.

    The selector at line 50-53 creates a map with bare transaction IDs as keys:

    acc[transaction.transactionID] = transaction;  // key: "abc123"

    This map is then passed as allTransactions to changeTransactionsReport at line 100. However, changeTransactionsReport in src/libs/actions/Transaction.ts:820 looks up transactions using Onyx collection-prefixed keys:

    const transactions = transactionIDs.map((id) => allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${id}`])

    This expects keys like "transactions_abc123", but finds keys like "abc123". Every lookup returns undefined, the resulting array is empty after filtering, and the operation fails silently.

    Why per diem is specifically affected: Per diem expenses always go to workspace expense reports (not IOU reports), so they always take the else branch at line 90 which calls changeTransactionsReport. The IOU report path (convertBulkTrackedExpensesToIOU) at line 77-89 was correctly refactored to use Object.values(selectedTransactions) (an array), but the expense report path was not.

    Note: This likely also affects non-per-diem unreported expenses being added to workspace expense reports, though per diem is the most visible case.

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

    In src/components/AddUnreportedExpenseFooter.tsx, change the selector to use Onyx collection-prefixed keys so that changeTransactionsReport can find the transactions:

    // Line 53: change from
    acc[transaction.transactionID] = transaction;
    // to
    acc[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`] = transaction;

    What alternative solutions did you explore? (Optional)

    An alternative would be to modify changeTransactionsReport to accept bare transaction IDs and look them up internally, but that would change the function's contract for all callers. The simpler fix is to align the key format in the selector.


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

  9. 7 remaining items

  10. parasharrajat commented on Feb 27, 2026

    @parasharrajat
    Member

    I am fixing it. From my PR.

  11. parasharrajat commented on Feb 27, 2026

    @parasharrajat
    Member

    Created the PR.

  12. melvin-bot commented on Feb 28, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  13. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 2, 2026
  14. rlinoz commented on Mar 2, 2026

    @rlinoz
    Contributor

    Reverting this works #81742

    But @parasharrajat is investigating if he can find a simple fix for it.

  15. rlinoz commented on Mar 2, 2026

    @rlinoz
    Contributor
  16. IuliiaHerets commented on Mar 2, 2026

    @IuliiaHerets

    @rlinoz Chrome / v9.3.27-7
    Passed

    Screen.Recording.2026-03-02.at.20.12.00.mp4
  17. removed
    DeployBlockerCashThis issue or pull request should block deployment
    on Mar 2, 2026
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.EngineeringExternalAdded to denote the issue can be worked on by a contributorHourlyKSv2ReviewingHas a PR in review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions