App icon indicating copy to clipboard operation
App copied to clipboard

[$175] [Exploratory] iOS Hold - Expense details are not displayed when partially approve

Open applause-bot[bot] opened this issue 1 week ago • 7 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.43-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: https://test-management.browserstack.com/projects/2219752/test-runs/84823078/folder/13176872/41237335/1995465055 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: iphone 11/26.2 App Component: Other

Action Performed:

Precondition: Admin create workspace and invite employee and approver

Steps:

  1. As employee submit two expenses to workspace chat
  2. As approver open the expense report but do not open expense thread
  3. As approver select one of the expenses and hold
  4. As approve partially approve the report

Expected Result:

Expense details page should be displayed

Actual Result:

Receipt, Amount, Merchant, Category, Description, Date fields are not displayed

Workaround:

Unknown

Platforms:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [ ] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/ef89559a-5d87-49b4-a256-854f1a6bd87a

View all open jobs on GitHub

Applause Internal Information Exported by: Chandana Kiran Bug ID: 7319583

Upwork Automation - Do Not Edit

applause-bot[bot] avatar Nov 20 '26 19:11 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/b12ea27e9b096b9ea2d4901ef6a4b14f5bdbb730d105e8f7df482a94a3358855

applause-bot[bot] avatar Nov 20 '26 19:11 applause-bot[bot]

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

Job added to Upwork: https://www.upwork.com/jobs/~022124889632366026491

⚠️ Preliminary analysis (low confidence) — the code supports a missing-thread-data explanation, but the reported failure is not confirmed.

Suspected cause

Partial approval moves the held expense into a separate report, leaving one approved expense on the original report. The UI then switches to single-expense rendering, which requires the expense’s thread report to be loaded locally.

If that thread is unavailable, the UI skips the entire expense-details component. This explains why Receipt, Amount, Merchant, Category, Description, and Date could disappear together—without those values being deleted.

Code evidence and alternative explanations

Counterevidence: A parent-report refetch already exists when a valid thread ID becomes available: ReportFetchHandler.tsx:466–483. Whether that response fails to hydrate the thread is unknown. Incomplete parent/action linkage or a server-response omission remain alternatives.

These references describe the inspected checkout, not independently verified source for version 9.5.43-0.

What must be confirmed

Capture the remaining expense’s thread report and parent/action linkage before and after partial approval, together with the approval and subsequent report-open responses. This will establish whether the problem is missing client hydration, incomplete linkage, or missing server data. A specific fix is premature without that evidence.

Production verification was blocked because log tools were unavailable.

Web verification results

🤖 Web test steps verification results: ❌ fail

The scenario requires separate employee and approver accounts, but only one pinned session was available. Execution was blocked before setup; this is not a confirmed product failure.

Step Status
Employee submission, approver hold and partial approval, and resulting expense detailsBlocked by the two-account requirement; none of the workflow assertions were verified.
❌
Preserve never-opened expense threadsNo expense threads were opened, but preservation throughout the workflow could not be verified.
❌

Possibly related

Approved expense shown on same report as a held one after approving involves the same partial-approval transition, but reports a different symptom and is not a confirmed duplicate.


Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.


view run

MelvinBot avatar Nov 23 '26 15:11 MelvinBot

Proposal

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

On iOS (narrow layout), when an approver opens a submitted 2-expense report without opening either expense thread, puts one of the expenses on hold, and partially approves the report, the remaining single approved expense does not display its expense details (Receipt, Amount, Merchant, Category, Description, Date). Only the report header and the submitted / approved actions are shown.

What is the root cause of that problem?

Two compounding bugs in src/pages/inbox/ReportFetchHandler.tsx break transaction-thread creation when a 2-expense report is reduced to a single expense via partial approval on narrow screens (MoneyRequestReportPreview/index.tsx:207-208 opens ROUTES.REPORT_WITH_ID → ReportScreen → ReportFetchHandler on small screens, whereas wide screens open SearchMoneyRequestReportPage, which already avoids both bugs):

  1. Unopened expenses have no transaction thread yet: useRequestMoneySubmission.ts:56 (and IOUAmountSubmission.ts:449) submits expenses with shouldGenerateTransactionThreadReport = false. Putting the first expense on hold via putOnHold (Hold.ts:99-102, 236-266) creates a thread only for that held expense, so the remaining unheld expense's IOU action still has childReportID === undefined.
  2. Stale transaction selection in createOneTransactionThread (ReportFetchHandler.tsx:159, 271-290): Partial approval (ReportWorkflow.ts:441-474 → getReportFromHoldRequestsOnyxData in Hold.ts:986-1005) marks the held expense's IOU action deleted in ONYXKEYS.COLLECTION.REPORT_ACTIONS<reportID> and moves the held transaction's reportID in ONYXKEYS.COLLECTION.TRANSACTION. Because useReportTransactionsCollection reads the derived key ONYXKEYS.DERIVED.REPORT_TRANSACTIONS_AND_VIOLATIONS whose recompute is flushed asynchronously via queueMicrotask (OnyxDerived/index.ts:278), ReportFetchHandler renders with the deleted IOU action in reportActions while reportTransactionsCollection still holds both [heldTransaction, remainingTransaction]:
    • Lines 161-165 correctly filter out the held expense via getAllNonDeletedTransactions(...), so visibleTransactions contains only the remaining unheld expense and getOneTransactionThreadReportID returns CONST.FAKE_REPORT_ID ('0').
    • That triggers createOneTransactionThread() (ReportFetchHandler.tsx:428-438). However, createOneTransactionThread ignores visibleTransactions and instead reads the unfiltered reportTransactionsCollection (line 272), filtering only pendingAction !== DELETE — which does not exclude the held expense (it was moved, not deleted).
    • Consequently, currentReportTransactions.at(0) picks the held expense instead of the remaining unheld expense, getIOUActionForReportID(reportID, oneTransactionID) resolves its deleted IOU action, and createTransactionThreadReport attaches the new thread to that deleted action instead of the remaining expense's live IOU action.
  3. Missing dependency prevents recovery (ReportFetchHandler.tsx:428-438): Once REPORT_TRANSACTIONS_AND_VIOLATIONS finishes recomputing and removes the held transaction, the effect's dependency array ([reportLoadingState.hasOnceLoadedReportActions, reportMetadata?.isOptimisticReport, transactionThreadReport?.reportID, transactionThreadReportID, isOffline]) does not include oneTransactionID (unlike SearchMoneyRequestReportPage.tsx:252, fixed in #80107). Because transactionThreadReportID stays CONST.FAKE_REPORT_ID and transactionThreadReport?.reportID stays undefined, the effect never re-runs.

Without transactionThreadReport?.reportID, MoneyReportContentCreated.tsx:58-97 stays permanently in its !hasThread branch — omitting <MoneyRequestView> and rendering only <MoneyReportView>, which hides report-level totals/breakdowns on a single-expense report (MoneyReportView.tsx:109-116, 245).

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

In src/pages/inbox/ReportFetchHandler.tsx:

  1. Derive the single remaining transaction and live IOU action from the already-filtered data instead of reading raw reportTransactionsCollection:
    • Remove the redundant reportTransactionsCollection subscription (line 159).
    • Resolve the single live IOU action via getOneTransactionThreadReportAction(report, chatReport, reportActions ?? [], isOffline, reportTransactionIDs) (using getTransactionThreadReportIDFromAction for transactionThreadReportID) — or derive oneTransaction from the non-deleted, non-pending-delete reportTransactions (matching visibleTransactions online and also excluding pendingAction === DELETE offline) and look up its live action with getIOUActionForTransactionID(reportActions, oneTransactionID, true).
    • Guard inside the FAKE_REPORT_ID effect / createOneTransactionThread so createTransactionThreadReport is only invoked when both oneTransaction and its live iouAction are defined, preventing accidental orphan-thread creation during transient renders.
  2. Include oneTransactionID (and iouAction?.reportActionID) in the useEffect dependency array at lines 428-438 (mirroring SearchMoneyRequestReportPage.tsx:252 from #80107) so that if the remaining transaction resolves after transactionThreadReportID first becomes CONST.FAKE_REPORT_ID, the effect reliably re-runs and creates the thread for the remaining expense.
  3. Add regression tests in tests/unit/ReportFetchHandlerTest.tsx covering:
    • A 2-expense report where the first expense's IOU action is marked deleted (partial approval) while REPORT_TRANSACTIONS_AND_VIOLATIONS still transiently contains both transactions — verifying createTransactionThreadReport is called with the remaining second expense and its live IOU action (not the held/deleted first expense).
    • A transient render where visibleTransactions is empty when transactionThreadReportID === CONST.FAKE_REPORT_ID, followed by the remaining transaction arriving — verifying no broken thread is created while empty and the thread is created once oneTransactionID resolves.

What alternative solutions did you explore? (Optional)

  • Calling openReport on the parent report again when transactionThreadReportID === CONST.FAKE_REPORT_ID: Does not resolve the issue because the unheld expense was created with shouldGenerateTransactionThreadReport = false and never opened, so the server has no childReportID for it until createTransactionThreadReport creates one.
  • Forcing thread creation in Hold.ts (getReportFromHoldRequestsOnyxData) for remaining unheld expenses: Overly coupled to partial approval and would miss other flows on ReportScreen that reduce a multi-expense report to one expense (e.g., deleting or moving an expense while REPORT_TRANSACTIONS_AND_VIOLATIONS lags behind REPORT_ACTIONS). Fixing ReportFetchHandler.tsx resolves partial approval and all analogous single-expense transitions uniformly.

ZeroNeroIV avatar Nov 26 '26 08:11 ZeroNeroIV

@rojiphil Whoops! This issue is 2 days overdue. Let's get this updated quick!

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