Skip to content

Commit

Permalink
revert extra changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Sep 19, 2024
1 parent 3897b39 commit e5ad3d6
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 20 deletions.
4 changes: 1 addition & 3 deletions src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 (
<OptionRowLHNData
Expand All @@ -172,7 +171,6 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
reportActions={itemReportActions}
parentReportAction={itemParentReportAction}
iouReportReportActions={itemIouReportReportActions}
iouReport={itemIouReport}
policy={itemPolicy}
invoiceReceiverPolicy={itemInvoiceReceiverPolicy}
personalDetails={personalDetails ?? {}}
Expand Down
3 changes: 0 additions & 3 deletions src/components/LHNOptionsList/OptionRowLHNData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function OptionRowLHNData({
receiptTransactions,
parentReportAction,
iouReportReportActions,
iouReport,
transaction,
lastReportActionTransaction,
transactionViolations,
Expand All @@ -45,7 +44,6 @@ function OptionRowLHNData({
// Note: ideally we'd have this as a dependent selector in onyx!
const item = SidebarUtils.getOptionData({
report: fullReport,
iouReport,
reportActions,
personalDetails,
preferredLocale: preferredLocale ?? CONST.LOCALES.DEFAULT,
Expand All @@ -68,7 +66,6 @@ function OptionRowLHNData({
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [
fullReport,
iouReport,
lastReportActionTransaction,
reportActions,
personalDetails,
Expand Down
3 changes: 0 additions & 3 deletions src/components/LHNOptionsList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ type OptionRowLHNDataProps = {
*/
iouReportReportActions: OnyxEntry<ReportActions>;

/** IOU report related to the last action of this report */
iouReport: OnyxEntry<Report>;

/** List of transaction violation */
transactionViolations: OnyxCollection<TransactionViolation[]>;

Expand Down
10 changes: 5 additions & 5 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ function getIOUReportIDOfLastAction(report: OnyxEntry<Report>): string | undefin
/**
* Get the last message text from the report directly or from other sources for special cases.
*/
function getLastMessageTextForReport(report: OnyxEntry<Report>, iouReport: OnyxEntry<Report>, lastActorDetails: Partial<PersonalDetails> | null, policy?: OnyxEntry<Policy>): string {
function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails: Partial<PersonalDetails> | null, policy?: OnyxEntry<Policy>): string {
const reportID = report?.reportID ?? '-1';
const lastReportAction = lastVisibleReportActions[reportID] ?? null;

Expand Down Expand Up @@ -622,15 +622,15 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, 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<typeof CONST.REPORT.ACTIONS.TYPE.IOU> =>
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),
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 1 addition & 3 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ function getOrderedReportIDs(
*/
function getOptionData({
report,
iouReport,
reportActions,
personalDetails,
preferredLocale,
Expand All @@ -246,7 +245,6 @@ function getOptionData({
invoiceReceiverPolicy,
}: {
report: OnyxEntry<Report>;
iouReport: OnyxEntry<Report>;
reportActions: OnyxEntry<ReportActions>;
personalDetails: OnyxEntry<PersonalDetailsList>;
preferredLocale: DeepValueOf<typeof CONST.LOCALES>;
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -7049,7 +7048,6 @@ function approveMoneyRequest(expenseReport: OnyxEntry<OnyxTypes.Report>, full?:
key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport?.reportID}`,
value: {
...expenseReport,
total,
lastMessageText: ReportActionsUtils.getReportActionText(optimisticApprovedReportAction),
lastMessageHtml: ReportActionsUtils.getReportActionHtml(optimisticApprovedReportAction),
stateNum: predictedNextState,
Expand Down
1 change: 0 additions & 1 deletion tests/perf-test/SidebarUtils.perf-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ describe('SidebarUtils', () => {
await measureFunction(() =>
SidebarUtils.getOptionData({
report,
iouReport: undefined,
reportActions,
personalDetails,
preferredLocale,
Expand Down

0 comments on commit e5ad3d6

Please sign in to comment.