|
1 | | -import React, {useCallback} from 'react'; |
| 1 | +import React from 'react'; |
2 | 2 | import type {OnyxEntry} from 'react-native-onyx'; |
3 | 3 | import useLocalize from '@hooks/useLocalize'; |
4 | 4 | import useOnyx from '@hooks/useOnyx'; |
@@ -63,27 +63,24 @@ function ReceiptScanFailedContent({action, report}: {action: OnyxTypes.ReportAct |
63 | 63 | const actionReportID = action.reportID; |
64 | 64 | // Prefer parentReportActionID (specific IOU action when `report` is a transaction thread). |
65 | 65 | // Fall back to childReportID match, then to the only IOU action for one-transaction reports. |
66 | | - const getIouActionSelector = useCallback( |
67 | | - (reportActions: OnyxEntry<OnyxTypes.ReportActions>): OnyxTypes.ReportAction | undefined => { |
68 | | - if (!isIouReport && parentReportActionID) { |
69 | | - const candidate = reportActions?.[parentReportActionID]; |
70 | | - if (isActionOfType(candidate, CONST.REPORT.ACTIONS.TYPE.IOU)) { |
71 | | - return candidate; |
72 | | - } |
| 66 | + const getIouActionSelector = (reportActions: OnyxEntry<OnyxTypes.ReportActions>): OnyxTypes.ReportAction | undefined => { |
| 67 | + if (!isIouReport && parentReportActionID) { |
| 68 | + const candidate = reportActions?.[parentReportActionID]; |
| 69 | + if (isActionOfType(candidate, CONST.REPORT.ACTIONS.TYPE.IOU)) { |
| 70 | + return candidate; |
73 | 71 | } |
74 | | - const iouActions = Object.values(reportActions ?? {}).filter((a): a is OnyxTypes.ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU> => |
75 | | - isActionOfType(a, CONST.REPORT.ACTIONS.TYPE.IOU), |
76 | | - ); |
77 | | - if (actionReportID) { |
78 | | - const match = iouActions.find((a) => a.childReportID === actionReportID); |
79 | | - if (match) { |
80 | | - return match; |
81 | | - } |
| 72 | + } |
| 73 | + const iouActions = Object.values(reportActions ?? {}).filter((a): a is OnyxTypes.ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU> => |
| 74 | + isActionOfType(a, CONST.REPORT.ACTIONS.TYPE.IOU), |
| 75 | + ); |
| 76 | + if (actionReportID) { |
| 77 | + const match = iouActions.find((a) => a.childReportID === actionReportID); |
| 78 | + if (match) { |
| 79 | + return match; |
82 | 80 | } |
83 | | - return iouActions.length === 1 ? iouActions.at(0) : undefined; |
84 | | - }, |
85 | | - [isIouReport, parentReportActionID, actionReportID], |
86 | | - ); |
| 81 | + } |
| 82 | + return iouActions.length === 1 ? iouActions.at(0) : undefined; |
| 83 | + }; |
87 | 84 | const [iouAction] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getNonEmptyStringOnyxID(iouReportID)}`, {selector: getIouActionSelector}); |
88 | 85 | const transactionID = getLinkedTransactionID(iouAction); |
89 | 86 | const [transactionViolations] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${getNonEmptyStringOnyxID(transactionID)}`); |
|
0 commit comments