Skip to content

Commit ae146ba

Browse files
committed
pass only id instead of report to getReimbursedMessage
1 parent 05d256a commit ae146ba

8 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/libs/OptionsListUtils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,15 +727,15 @@ function getLastMessageTextForReport({
727727
} else if (isReimbursementQueuedAction(lastReportAction)) {
728728
lastMessageTextFromReport = getReimbursementQueuedActionMessage({reportAction: lastReportAction, translate, formatPhoneNumber: formatPhoneNumberPhoneUtils, report});
729729
} else if (isReimbursementDeQueuedOrCanceledAction(lastReportAction)) {
730-
lastMessageTextFromReport = getReimbursementDeQueuedOrCanceledActionMessage(translate, lastReportAction, report);
730+
lastMessageTextFromReport = getReimbursementDeQueuedOrCanceledActionMessage(translate, lastReportAction, report?.ownerAccountID);
731731
} else if (isDeletedParentAction(lastReportAction) && reportUtilsIsChatReport(report)) {
732732
lastMessageTextFromReport = getDeletedParentActionMessageForChatReport(lastReportAction);
733733
} else if (isPendingRemove(lastReportAction) && report?.reportID && isThreadParentMessage(lastReportAction, report.reportID)) {
734734
lastMessageTextFromReport = translate('parentReportAction.hiddenMessage');
735735
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED)) {
736736
lastMessageTextFromReport = getMarkedReimbursedMessage(translate, lastReportAction);
737737
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.REIMBURSED)) {
738-
lastMessageTextFromReport = getReimbursedMessage(translate, lastReportAction, report);
738+
lastMessageTextFromReport = getReimbursedMessage(translate, lastReportAction, report?.ownerAccountID);
739739
} else if (isReportMessageAttachment({text: report?.lastMessageText ?? '', html: report?.lastMessageHtml, type: ''})) {
740740
lastMessageTextFromReport = `[${translate('common.attachment')}]`;
741741
} else if (isModifiedExpenseAction(lastReportAction)) {

src/libs/ReportActionsUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ function getMarkedReimbursedMessage(translate: LocalizedTranslate, reportAction:
459459
return translate('iou.paidElsewhere', {comment: originalMessage?.message?.trim()});
460460
}
461461

462-
function getReimbursedMessage(translate: LocalizedTranslate, reportAction: OnyxInputOrEntry<ReportAction>, report: OnyxEntry<Report>, currentUserAccountID?: number): string {
462+
function getReimbursedMessage(translate: LocalizedTranslate, reportAction: OnyxInputOrEntry<ReportAction>, reportOwnerAccountID: number | undefined, currentUserAccountID?: number): string {
463463
const effectiveCurrentUserAccountID = currentUserAccountID ?? deprecatedCurrentUserAccountID ?? CONST.DEFAULT_NUMBER_ID;
464464
const originalMessage = getOriginalMessage(reportAction) as OriginalMessageReimbursed | undefined;
465465

@@ -488,7 +488,7 @@ function getReimbursedMessage(translate: LocalizedTranslate, reportAction: OnyxI
488488
const {debitBankAccountLast4, creditBankAccountLast4, expectedDate, isInvoiceOrBill, isSubmitterAddingBankAccount, stripePaymentType} = originalMessage;
489489

490490
// Resolve submitter from report owner
491-
const submitterAccountID = report?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID;
491+
const submitterAccountID = reportOwnerAccountID ?? CONST.DEFAULT_NUMBER_ID;
492492
const submitterLogin = getPersonalDetailsByIDs({accountIDs: [submitterAccountID], currentUserAccountID: effectiveCurrentUserAccountID}).at(0)?.login ?? '';
493493
const isCurrentUser = submitterAccountID === effectiveCurrentUserAccountID;
494494

src/libs/ReportNameUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ function computeReportNameBasedOnReportAction(
476476
}
477477

478478
if (isReimbursementDeQueuedOrCanceledAction(parentReportAction)) {
479-
return getReimbursementDeQueuedOrCanceledActionMessage(translate, parentReportAction, parentReport);
479+
return getReimbursementDeQueuedOrCanceledActionMessage(translate, parentReportAction, parentReport?.ownerAccountID);
480480
}
481481
if (isRejectedAction(parentReportAction)) {
482482
return translate('iou.rejectedThisReport');

src/libs/ReportUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3985,7 +3985,7 @@ function getReimbursementQueuedActionMessage({
39853985
function getReimbursementDeQueuedOrCanceledActionMessage(
39863986
translate: LocalizedTranslate,
39873987
reportAction: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED | typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACH_CANCELED>>,
3988-
report: OnyxEntry<Report>,
3988+
reportOwnerAccountID: number | undefined,
39893989
): string {
39903990
const originalMessage = getOriginalMessage(reportAction);
39913991
const amount = originalMessage?.amount;
@@ -3994,7 +3994,7 @@ function getReimbursementDeQueuedOrCanceledActionMessage(
39943994
if (originalMessage?.cancellationReason === CONST.REPORT.CANCEL_PAYMENT_REASONS.ADMIN || originalMessage?.cancellationReason === CONST.REPORT.CANCEL_PAYMENT_REASONS.USER) {
39953995
return translate('iou.adminCanceledRequest');
39963996
}
3997-
const submitterDisplayName = getDisplayNameForParticipant({accountID: report?.ownerAccountID, shouldUseShortForm: true, formatPhoneNumber: formatPhoneNumberPhoneUtils}) ?? '';
3997+
const submitterDisplayName = getDisplayNameForParticipant({accountID: reportOwnerAccountID, shouldUseShortForm: true, formatPhoneNumber: formatPhoneNumberPhoneUtils}) ?? '';
39983998
return translate('iou.canceledRequest', formattedAmount, submitterDisplayName);
39993999
}
40004000

src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ const ContextMenuActions: ContextMenuAction[] = [
872872
const modifyExpenseMessage = Parser.htmlToMarkdown(modifyExpenseMessageWithHTML);
873873
Clipboard.setString(modifyExpenseMessage);
874874
} else if (isReimbursementDeQueuedOrCanceledAction(reportAction)) {
875-
const displayMessage = getReimbursementDeQueuedOrCanceledActionMessage(translate, reportAction, report);
875+
const displayMessage = getReimbursementDeQueuedOrCanceledActionMessage(translate, reportAction, report?.ownerAccountID);
876876
Clipboard.setString(displayMessage);
877877
} else if (isMoneyRequestAction(reportAction)) {
878878
const displayMessage = getIOUReportActionDisplayMessage(translate, reportAction, transaction, report, bankAccountList);
@@ -999,7 +999,7 @@ const ContextMenuActions: ContextMenuAction[] = [
999999
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED)) {
10001000
Clipboard.setString(getMarkedReimbursedMessage(translate, reportAction));
10011001
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.REIMBURSED)) {
1002-
Clipboard.setString(getReimbursedMessage(translate, reportAction, report, currentUserPersonalDetails.accountID));
1002+
Clipboard.setString(getReimbursedMessage(translate, reportAction, report?.ownerAccountID, currentUserPersonalDetails.accountID));
10031003
} else if (isReimbursementQueuedAction(reportAction)) {
10041004
Clipboard.setString(
10051005
getReimbursementQueuedActionMessage({reportAction, translate, formatPhoneNumber: formatPhoneNumberPhoneUtils, report, shouldUseShortDisplayName: false}),

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ function ActionContentRouter({
153153
const actionReport = originalReport ?? report;
154154
const actionReportID = originalReportID ?? reportID;
155155
const policyID = report?.policyID;
156+
const reportOwnerAccountID = report?.ownerAccountID;
156157

157158
if (isIOURequestReportAction(action)) {
158159
const moneyRequestOriginalMessage = isMoneyRequestAction(action) ? getOriginalMessage(action) : undefined;
@@ -246,7 +247,7 @@ function ActionContentRouter({
246247
return (
247248
<ReimbursementDeQueuedContent
248249
action={action}
249-
report={report}
250+
reportOwnerAccountID={reportOwnerAccountID}
250251
/>
251252
);
252253
}
@@ -281,7 +282,7 @@ function ActionContentRouter({
281282
return (
282283
<ReimbursedContent
283284
action={action}
284-
report={report}
285+
reportOwnerAccountID={reportOwnerAccountID}
285286
/>
286287
);
287288
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import React from 'react';
2-
import type {OnyxEntry} from 'react-native-onyx';
32
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
43
import useLocalize from '@hooks/useLocalize';
54
import {getReimbursedMessage} from '@libs/ReportActionsUtils';
65
import ReportActionItemBasicMessage from '@pages/inbox/report/ReportActionItemBasicMessage';
7-
import type {Report, ReportAction} from '@src/types/onyx';
6+
import type {ReportAction} from '@src/types/onyx';
87

98
type ReimbursedContentProps = {
109
action: ReportAction;
11-
report: OnyxEntry<Report>;
10+
reportOwnerAccountID: number | undefined;
1211
};
1312

14-
function ReimbursedContent({action, report}: ReimbursedContentProps) {
13+
function ReimbursedContent({action, reportOwnerAccountID}: ReimbursedContentProps) {
1514
const {translate} = useLocalize();
1615
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
17-
const message = getReimbursedMessage(translate, action, report, currentUserAccountID);
16+
const message = getReimbursedMessage(translate, action, reportOwnerAccountID, currentUserAccountID);
1817

1918
return <ReportActionItemBasicMessage message={message} />;
2019
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import useLocalize from '@hooks/useLocalize';
44
import {getReimbursementDeQueuedOrCanceledActionMessage} from '@libs/ReportUtils';
55
import ReportActionItemBasicMessage from '@pages/inbox/report/ReportActionItemBasicMessage';
66
import type CONST from '@src/CONST';
7-
import type {Report, ReportAction} from '@src/types/onyx';
7+
import type {ReportAction} from '@src/types/onyx';
88

99
type ReimbursementDeQueuedContentProps = {
1010
action: ReportAction;
11-
report: OnyxEntry<Report>;
11+
reportOwnerAccountID: number | undefined;
1212
};
1313

14-
function ReimbursementDeQueuedContent({action, report}: ReimbursementDeQueuedContentProps) {
14+
function ReimbursementDeQueuedContent({action, reportOwnerAccountID}: ReimbursementDeQueuedContentProps) {
1515
const {translate} = useLocalize();
1616
const message = getReimbursementDeQueuedOrCanceledActionMessage(
1717
translate,
1818
action as OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED | typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACH_CANCELED>>,
19-
report,
19+
reportOwnerAccountID,
2020
);
2121

2222
return <ReportActionItemBasicMessage message={message} />;

0 commit comments

Comments
 (0)