Skip to content

Commit 6b5fb76

Browse files
fix: resolve parent report action from raw Onyx collection
Use direct REPORT_ACTIONS key lookup for requestParentReportAction so Hold/Unhold keep working when the parent IOU is filtered or unpaginated. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 56bf977 commit 6b5fb76

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/components/MoneyReportTransactionThreadContext.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import React, {createContext, useContext} from 'react';
22
import type {ReactNode} from 'react';
3+
import useOnyx from '@hooks/useOnyx';
34
import useTransactionThreadReport from '@hooks/useTransactionThreadReport';
5+
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
46
import {getOriginalMessage, isMoneyRequestAction} from '@libs/ReportActionsUtils';
57
import type CONST from '@src/CONST';
8+
import ONYXKEYS from '@src/ONYXKEYS';
69
import type * as OnyxTypes from '@src/types/onyx';
710

811
type MoneyReportTransactionThreadContextValue = {
@@ -28,10 +31,12 @@ type MoneyReportTransactionThreadProviderProps = {
2831

2932
function MoneyReportTransactionThreadProvider({reportID, children}: MoneyReportTransactionThreadProviderProps) {
3033
const {transactionThreadReportID, transactionThreadReport, reportActions} = useTransactionThreadReport(reportID);
34+
const [reportActionsForParent] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getNonEmptyStringOnyxID(reportID)}`);
3135

32-
const requestParentReportAction =
33-
reportActions?.find((action): action is OnyxTypes.ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU> => action.reportActionID === transactionThreadReport?.parentReportActionID) ??
34-
null;
36+
// Parent lookup uses the raw Onyx collection so Hold/Unhold still work when the parent IOU is
37+
// filtered from the report view (e.g. deleted money request) or outside the paginated window.
38+
const parentReportAction = transactionThreadReport?.parentReportActionID ? reportActionsForParent?.[transactionThreadReport.parentReportActionID] : undefined;
39+
const requestParentReportAction = isMoneyRequestAction(parentReportAction) ? parentReportAction : null;
3540

3641
const iouTransactionID = isMoneyRequestAction(requestParentReportAction) ? getOriginalMessage(requestParentReportAction)?.IOUTransactionID : undefined;
3742

0 commit comments

Comments
 (0)