From 3de24ae9ce533e3d174089ef5f2da7a128988f6e Mon Sep 17 00:00:00 2001 From: Lukasz Modzelewski Date: Thu, 23 Apr 2026 16:00:24 +0200 Subject: [PATCH 1/5] refactor: Extract IouReportActionMessage from ReportActionItemMessage --- .../inbox/report/ReportActionItemMessage.tsx | 60 +++----- .../actionContents/IouReportActionMessage.tsx | 128 ++++++++++++++++++ 2 files changed, 144 insertions(+), 44 deletions(-) create mode 100644 src/pages/inbox/report/actionContents/IouReportActionMessage.tsx diff --git a/src/pages/inbox/report/ReportActionItemMessage.tsx b/src/pages/inbox/report/ReportActionItemMessage.tsx index 4c90e169a3e0..62460451979b 100644 --- a/src/pages/inbox/report/ReportActionItemMessage.tsx +++ b/src/pages/inbox/report/ReportActionItemMessage.tsx @@ -5,12 +5,9 @@ import {View} from 'react-native'; import Button from '@components/Button'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; -import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; -import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; import Navigation from '@libs/Navigation/Navigation'; import { - getLinkedTransactionID, getMemberChangeMessageFragment, getOriginalMessage, getReportActionMessage, @@ -23,11 +20,11 @@ import { isReimbursementDirectionInformationRequiredAction, isThreadParentMessage, } from '@libs/ReportActionsUtils'; -import {getIOUReportActionDisplayMessage, getReportName, hasMissingInvoiceBankAccount, isSettled} from '@libs/ReportUtils'; +import {getReportName} from '@libs/ReportUtils'; import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {ReportAction} from '@src/types/onyx'; +import IouReportActionMessage from './actionContents/IouReportActionMessage'; import TextCommentFragment from './comment/TextCommentFragment'; import ReportActionItemFragment from './ReportActionItemFragment'; @@ -51,12 +48,18 @@ type ReportActionItemMessageProps = { function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHidden = false}: ReportActionItemMessageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); - const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(getLinkedTransactionID(action))}`); - const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); - const fragments = getReportActionMessageFragments(translate, action); - const isIOUReport = isMoneyRequestAction(action); + if (isMoneyRequestAction(action)) { + return ( + + ); + } if (isMemberChangeAction(action)) { // This will be fixed: https://github.com/Expensify/App/issues/76852 @@ -118,19 +121,12 @@ function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHid ); } - let iouMessage: string | undefined; - if (isIOUReport) { - const originalMessage = action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? getOriginalMessage(action) : null; - const iouReportID = originalMessage?.IOUReportID; - if (iouReportID) { - iouMessage = getIOUReportActionDisplayMessage(translate, action, transaction, report, bankAccountList); - } - } - const isApprovedOrSubmittedReportAction = isApprovedOrSubmittedReportActionUtils(action); const isHoldReportAction = [CONST.REPORT.ACTIONS.TYPE.HOLD, CONST.REPORT.ACTIONS.TYPE.UNHOLD].some((type) => type === action.actionName); + const fragments = getReportActionMessageFragments(translate, action); + /** * Get the ReportActionItemFragments * @param shouldWrapInText determines whether the fragments are wrapped in a Text component @@ -143,7 +139,6 @@ function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHid key={`actionFragment-${action.reportActionID}-${index}`} reportActionID={action.reportActionID} fragment={fragment} - iouMessage={iouMessage} isThreadParentMessage={isThreadParentMessage(action, reportID)} pendingAction={action.pendingAction} actionName={action.actionName} @@ -167,33 +162,10 @@ function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHid return shouldWrapInText ? {reportActionItemFragments} : reportActionItemFragments; }; - const openWorkspaceInvoicesPage = () => { - const policyID = report?.policyID; - - if (!policyID) { - return; - } - - Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policyID)); - }; - - const shouldShowAddBankAccountButton = action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && hasMissingInvoiceBankAccount(reportID) && !isSettled(reportID); - return ( {!isHidden ? ( - <> - {renderReportActionItemFragments(isApprovedOrSubmittedReportAction)} - {shouldShowAddBankAccountButton && ( -