Skip to content

Commit 776ef1a

Browse files
authored
Merge pull request Expensify#86972 from dukenv0307/fix/66411-part-18
refactor handleMoneyRequestStepDistanceNavigation to use conciergeReportID from useOnyx
2 parents ef306d3 + 973a441 commit 776ef1a

15 files changed

Lines changed: 252 additions & 16 deletions

File tree

src/components/ReportActionItem/MovedTransactionAction.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function MovedTransactionAction({action, emptyHTML, childReport, originalReport}
3434

3535
const [toReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${toReportID}`);
3636
const [fromReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${fromReportID}`);
37+
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
3738

3839
const isPendingDelete = fromReport?.pendingFields?.preview === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
3940
// When the transaction is moved from personal space (unreported), fromReportID will be "0" which doesn't exist in allReports
@@ -46,7 +47,7 @@ function MovedTransactionAction({action, emptyHTML, childReport, originalReport}
4647
return emptyHTML;
4748
}
4849

49-
const message = getMovedTransactionMessage(translate, action);
50+
const message = getMovedTransactionMessage(translate, action, conciergeReportID);
5051

5152
if (hasReasoning(action)) {
5253
return (

src/libs/ReportNameUtils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,7 @@ function computeReportNameBasedOnReportAction(
422422
reportPolicy: Policy | undefined,
423423
parentReport: Report | undefined,
424424
personalDetailsList: OnyxEntry<PersonalDetailsList>,
425-
// TODO: Make this required when https://github.com/Expensify/App/issues/66411 is done
426-
conciergeReportID?: string,
425+
conciergeReportID: string | undefined,
427426
): string | undefined {
428427
if (!parentReportAction) {
429428
return undefined;
@@ -533,7 +532,7 @@ function computeReportNameBasedOnReportAction(
533532
}
534533

535534
if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION)) {
536-
return Parser.htmlToText(getMovedTransactionMessage(translate, parentReportAction));
535+
return Parser.htmlToText(getMovedTransactionMessage(translate, parentReportAction, conciergeReportID));
537536
}
538537

539538
if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) {

src/libs/ReportUtils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6951,8 +6951,7 @@ function getDeletedTransactionMessage(translate: LocalizedTranslate, action: Rep
69516951
return message;
69526952
}
69536953

6954-
// TODO: conciergeReportID will be required eventually. Refactor issue: https://github.com/Expensify/App/issues/66411
6955-
function getMovedTransactionMessage(translate: LocalizedTranslate, action: ReportAction, conciergeReportID?: string) {
6954+
function getMovedTransactionMessage(translate: LocalizedTranslate, action: ReportAction, conciergeReportID: string | undefined) {
69566955
const movedTransactionOriginalMessage = getOriginalMessage(action) ?? {};
69576956
const {toReportID, fromReportID} = movedTransactionOriginalMessage as OriginalMessageMovedTransaction;
69586957

src/libs/SidebarUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ function getOptionData({
11291129
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_OWNERSHIP) {
11301130
result.alternateText = Parser.htmlToText(getUpdatedOwnershipMessage(translate, lastAction, policy));
11311131
} else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION)) {
1132-
result.alternateText = Parser.htmlToText(getMovedTransactionMessage(translate, lastAction));
1132+
result.alternateText = Parser.htmlToText(getMovedTransactionMessage(translate, lastAction, conciergeReportID));
11331133
} else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.SETTLEMENT_ACCOUNT_LOCKED)) {
11341134
result.alternateText = Parser.htmlToText(getSettlementAccountLockedMessage(translate, lastAction));
11351135
} else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastActorDisplayName && lastMessageTextFromReport) {

src/libs/actions/IOU/MoneyRequest.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ type MoneyRequestStepDistanceNavigationParams = {
176176
amountOwed: OnyxEntry<number>;
177177
userBillingGracePeriodEnds: OnyxCollection<BillingGraceEndPeriod>;
178178
ownerBillingGracePeriodEnd?: OnyxEntry<number>;
179+
conciergeReportID: string | undefined;
179180
};
180181

181182
function createTransaction({
@@ -297,6 +298,7 @@ function getMoneyRequestParticipantOptions(
297298
report: OnyxEntry<Report>,
298299
policy: OnyxEntry<Policy>,
299300
personalDetails: OnyxEntry<PersonalDetailsList>,
301+
conciergeReportID: string | undefined,
300302
privateIsArchived?: boolean,
301303
reportAttributesDerived?: ReportAttributesDerivedValue['reports'],
302304
): Array<Participant | OptionData> {
@@ -305,8 +307,7 @@ function getMoneyRequestParticipantOptions(
305307
const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID;
306308
return participantAccountID
307309
? getParticipantsOption(participant, personalDetails)
308-
: // TODO: We'll pass the conciergeReportID in the next PR. Refactor issue: https://github.com/Expensify/App/issues/66411
309-
getReportOption(participant, privateIsArchived, policy, personalDetails, undefined, reportAttributesDerived);
310+
: getReportOption(participant, privateIsArchived, policy, personalDetails, conciergeReportID, reportAttributesDerived);
310311
});
311312
}
312313

@@ -606,6 +607,7 @@ function handleMoneyRequestStepDistanceNavigation({
606607
amountOwed,
607608
userBillingGracePeriodEnds,
608609
ownerBillingGracePeriodEnd,
610+
conciergeReportID,
609611
}: MoneyRequestStepDistanceNavigationParams) {
610612
const isManualDistance = manualDistance !== undefined;
611613
const isOdometerDistance = odometerDistance !== undefined;
@@ -628,7 +630,7 @@ function handleMoneyRequestStepDistanceNavigation({
628630
// to the confirm step.
629631
// If the user started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page.
630632
if (report?.reportID && !isArchivedExpenseReport && iouType !== CONST.IOU.TYPE.CREATE) {
631-
const participants = getMoneyRequestParticipantOptions(currentUserAccountID, report, policy, personalDetails, privateIsArchived, reportAttributesDerived);
633+
const participants = getMoneyRequestParticipantOptions(currentUserAccountID, report, policy, personalDetails, conciergeReportID, privateIsArchived, reportAttributesDerived);
632634

633635
setDistanceRequestData?.(participants);
634636
if (shouldSkipConfirmation) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ const ContextMenuActions: ContextMenuAction[] = [
11121112
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL) || isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.REROUTE)) {
11131113
setClipboardMessage(getChangedApproverActionMessage(translate, reportAction));
11141114
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION)) {
1115-
setClipboardMessage(getMovedTransactionMessage(translate, reportAction));
1115+
setClipboardMessage(getMovedTransactionMessage(translate, reportAction, conciergeReportID));
11161116
} else if (isMovedAction(reportAction)) {
11171117
setClipboardMessage(getMovedActionMessage(translate, reportAction, originalReport));
11181118
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_CARD_FRAUD_ALERT)) {

src/pages/iou/request/step/IOURequestStepDistance.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ function IOURequestStepDistance({
109109
const [betas] = useOnyx(ONYXKEYS.BETAS);
110110
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
111111
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
112+
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
112113

113114
const isEditing = action === CONST.IOU.ACTION.EDIT;
114115
const isEditingSplit = (iouType === CONST.IOU.TYPE.SPLIT || iouType === CONST.IOU.TYPE.SPLIT_EXPENSE) && isEditing;
@@ -343,6 +344,7 @@ function IOURequestStepDistance({
343344
amountOwed,
344345
userBillingGracePeriodEnds,
345346
ownerBillingGracePeriodEnd,
347+
conciergeReportID,
346348
});
347349
}, [
348350
iouType,
@@ -380,6 +382,7 @@ function IOURequestStepDistance({
380382
amountOwed,
381383
userBillingGracePeriodEnds,
382384
ownerBillingGracePeriodEnd,
385+
conciergeReportID,
383386
]);
384387

385388
const getError = () => {

src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function IOURequestStepDistanceGPS({
6464
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
6565
const [betas] = useOnyx(ONYXKEYS.BETAS);
6666
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
67+
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
6768
const isEditing = action === CONST.IOU.ACTION.EDIT;
6869
const isCreatingNewRequest = !isEditing;
6970
// eslint-disable-next-line rulesdir/no-negated-variables
@@ -135,6 +136,7 @@ function IOURequestStepDistanceGPS({
135136
amountOwed,
136137
userBillingGracePeriodEnds,
137138
ownerBillingGracePeriodEnd,
139+
conciergeReportID,
138140
});
139141
};
140142

src/pages/iou/request/step/IOURequestStepDistanceManual.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ function IOURequestStepDistanceManual({
100100
const [betas] = useOnyx(ONYXKEYS.BETAS);
101101
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
102102
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
103+
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
103104

104105
const [splitDraftTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`);
105106

@@ -252,6 +253,7 @@ function IOURequestStepDistanceManual({
252253
amountOwed,
253254
userBillingGracePeriodEnds,
254255
ownerBillingGracePeriodEnd,
256+
conciergeReportID,
255257
});
256258
},
257259
[
@@ -298,6 +300,7 @@ function IOURequestStepDistanceManual({
298300
isSelfTourViewed,
299301
amountOwed,
300302
ownerBillingGracePeriodEnd,
303+
conciergeReportID,
301304
],
302305
);
303306

src/pages/iou/request/step/IOURequestStepDistanceMap.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function IOURequestStepDistanceMap({
106106
const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES);
107107
const [betas] = useOnyx(ONYXKEYS.BETAS);
108108
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
109+
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
109110
const isEditing = action === CONST.IOU.ACTION.EDIT;
110111
const isEditingSplit = (iouType === CONST.IOU.TYPE.SPLIT || iouType === CONST.IOU.TYPE.SPLIT_EXPENSE) && isEditing;
111112
const currentTransaction = isEditingSplit && !isEmpty(splitDraftTransaction) ? splitDraftTransaction : transaction;
@@ -337,6 +338,7 @@ function IOURequestStepDistanceMap({
337338
amountOwed,
338339
userBillingGracePeriodEnds,
339340
ownerBillingGracePeriodEnd,
341+
conciergeReportID,
340342
});
341343
}, [
342344
iouType,
@@ -374,6 +376,7 @@ function IOURequestStepDistanceMap({
374376
amountOwed,
375377
userBillingGracePeriodEnds,
376378
ownerBillingGracePeriodEnd,
379+
conciergeReportID,
377380
]);
378381

379382
const getError = () => {

0 commit comments

Comments
 (0)