Skip to content

Commit 1c7073e

Browse files
MelvinBotdukenv0307
andcommitted
Remove redundant useCallback (React Compiler handles memoization)
Co-authored-by: dukenv0307 <dukenv0307@users.noreply.github.com>
1 parent 96e01d4 commit 1c7073e

1 file changed

Lines changed: 17 additions & 20 deletions

File tree

src/pages/inbox/report/actionContents/SimpleMessageContent.tsx

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useCallback} from 'react';
1+
import React from 'react';
22
import type {OnyxEntry} from 'react-native-onyx';
33
import useLocalize from '@hooks/useLocalize';
44
import useOnyx from '@hooks/useOnyx';
@@ -63,27 +63,24 @@ function ReceiptScanFailedContent({action, report}: {action: OnyxTypes.ReportAct
6363
const actionReportID = action.reportID;
6464
// Prefer parentReportActionID (specific IOU action when `report` is a transaction thread).
6565
// 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;
7371
}
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;
8280
}
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+
};
8784
const [iouAction] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getNonEmptyStringOnyxID(iouReportID)}`, {selector: getIouActionSelector});
8885
const transactionID = getLinkedTransactionID(iouAction);
8986
const [transactionViolations] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${getNonEmptyStringOnyxID(transactionID)}`);

0 commit comments

Comments
 (0)