From e5ad3d6549c2ee96dd0e5c4028b6c4b48fa84842 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 19 Sep 2024 15:46:44 +0700 Subject: [PATCH] revert extra changes --- src/components/LHNOptionsList/LHNOptionsList.tsx | 4 +--- src/components/LHNOptionsList/OptionRowLHNData.tsx | 3 --- src/components/LHNOptionsList/types.ts | 3 --- src/libs/OptionsListUtils.ts | 10 +++++----- src/libs/SidebarUtils.ts | 4 +--- src/libs/actions/IOU.ts | 2 -- tests/perf-test/SidebarUtils.perf-test.ts | 1 - 7 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index bad7fec04831..624e8f18e69e 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -132,7 +132,6 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio const iouReportIDOfLastAction = OptionsListUtils.getIOUReportIDOfLastAction(itemFullReport); const itemIouReportReportActions = iouReportIDOfLastAction ? reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportIDOfLastAction}`] : undefined; - const itemIouReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${iouReportIDOfLastAction}`]; const itemPolicy = policy?.[`${ONYXKEYS.COLLECTION.POLICY}${itemFullReport?.policyID}`]; const transactionID = ReportActionsUtils.isMoneyRequestAction(itemParentReportAction) @@ -163,7 +162,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio } : null; } - const lastMessageTextFromReport = OptionsListUtils.getLastMessageTextForReport(itemFullReport, itemIouReport, lastActorDetails, itemPolicy); + const lastMessageTextFromReport = OptionsListUtils.getLastMessageTextForReport(itemFullReport, lastActorDetails, itemPolicy); return ( ; - /** IOU report related to the last action of this report */ - iouReport: OnyxEntry; - /** List of transaction violation */ transactionViolations: OnyxCollection; diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index a08f167f61d3..afedd308371c 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -588,7 +588,7 @@ function getIOUReportIDOfLastAction(report: OnyxEntry): string | undefin /** * Get the last message text from the report directly or from other sources for special cases. */ -function getLastMessageTextForReport(report: OnyxEntry, iouReport: OnyxEntry, lastActorDetails: Partial | null, policy?: OnyxEntry): string { +function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails: Partial | null, policy?: OnyxEntry): string { const reportID = report?.reportID ?? '-1'; const lastReportAction = lastVisibleReportActions[reportID] ?? null; @@ -622,15 +622,15 @@ function getLastMessageTextForReport(report: OnyxEntry, iouReport: OnyxE const properSchemaForMoneyRequestMessage = ReportUtils.getReportPreviewMessage(report, lastReportAction, true, false, null, true); lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(properSchemaForMoneyRequestMessage); } else if (ReportActionUtils.isReportPreviewAction(lastReportAction)) { - const iouReportValue = iouReport ?? ReportUtils.getReportOrDraftReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastReportAction)); - const lastIOUMoneyReportAction = allSortedReportActions[iouReportValue?.reportID ?? '-1']?.find( + const iouReport = ReportUtils.getReportOrDraftReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastReportAction)); + const lastIOUMoneyReportAction = allSortedReportActions[iouReport?.reportID ?? '-1']?.find( (reportAction, key): reportAction is ReportAction => ReportActionUtils.shouldReportActionBeVisible(reportAction, key) && reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && ReportActionUtils.isMoneyRequestAction(reportAction), ); const reportPreviewMessage = ReportUtils.getReportPreviewMessage( - !isEmptyObject(iouReportValue) ? iouReportValue : null, + !isEmptyObject(iouReport) ? iouReport : null, lastIOUMoneyReportAction, true, ReportUtils.isChatReport(report), @@ -764,7 +764,7 @@ function createOption( const lastActorDetails = personalDetailMap[report.lastActorAccountID ?? -1] ?? null; const lastActorDisplayName = getLastActorDisplayName(lastActorDetails, hasMultipleParticipants); - const lastMessageTextFromReport = getLastMessageTextForReport(report, undefined, lastActorDetails); + const lastMessageTextFromReport = getLastMessageTextForReport(report, lastActorDetails); let lastMessageText = lastMessageTextFromReport; const lastAction = lastVisibleReportActions[report.reportID]; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 8fc17dcf5339..d056f111695e 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -234,7 +234,6 @@ function getOrderedReportIDs( */ function getOptionData({ report, - iouReport, reportActions, personalDetails, preferredLocale, @@ -246,7 +245,6 @@ function getOptionData({ invoiceReceiverPolicy, }: { report: OnyxEntry; - iouReport: OnyxEntry; reportActions: OnyxEntry; personalDetails: OnyxEntry; preferredLocale: DeepValueOf; @@ -392,7 +390,7 @@ function getOptionData({ let lastMessageTextFromReport = lastMessageTextFromReportProp; if (!lastMessageTextFromReport) { - lastMessageTextFromReport = OptionsListUtils.getLastMessageTextForReport(report, iouReport, lastActorDetails, policy); + lastMessageTextFromReport = OptionsListUtils.getLastMessageTextForReport(report, lastActorDetails, policy); } // We need to remove sms domain in case the last message text has a phone number mention with sms domain. diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 7c45cab582c4..6f694fd41403 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6745,7 +6745,6 @@ function getPayMoneyRequestParams( key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, value: { ...iouReport, - total, lastMessageText: ReportActionsUtils.getReportActionText(optimisticIOUReportAction), lastMessageHtml: ReportActionsUtils.getReportActionHtml(optimisticIOUReportAction), hasOutstandingChildRequest: false, @@ -7049,7 +7048,6 @@ function approveMoneyRequest(expenseReport: OnyxEntry, full?: key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport?.reportID}`, value: { ...expenseReport, - total, lastMessageText: ReportActionsUtils.getReportActionText(optimisticApprovedReportAction), lastMessageHtml: ReportActionsUtils.getReportActionHtml(optimisticApprovedReportAction), stateNum: predictedNextState, diff --git a/tests/perf-test/SidebarUtils.perf-test.ts b/tests/perf-test/SidebarUtils.perf-test.ts index 47595b207277..4a6b12d726d9 100644 --- a/tests/perf-test/SidebarUtils.perf-test.ts +++ b/tests/perf-test/SidebarUtils.perf-test.ts @@ -102,7 +102,6 @@ describe('SidebarUtils', () => { await measureFunction(() => SidebarUtils.getOptionData({ report, - iouReport: undefined, reportActions, personalDetails, preferredLocale,