Skip to content

Commit 08c4a43

Browse files
committed
fix: fix problem with active policy
1 parent eb5bb7d commit 08c4a43

2 files changed

Lines changed: 30 additions & 20 deletions

File tree

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -442,17 +442,16 @@ function IOURequestStepScan({
442442
return;
443443
}
444444

445-
// If the initial transaction already has the participants selected, then we can skip the participants step and go straight to the confirmation step.
446-
if (initialTransaction?.participants && initialTransaction?.participants.length > 0) {
447-
const setParticipantsPromises = files.map((receiptFile) => setMoneyRequestParticipants(receiptFile.transactionID, initialTransaction?.participants));
448-
Promise.all(setParticipantsPromises).then(() => navigateToConfirmationPage(false, initialTransaction?.reportID));
449-
return;
450-
}
451-
452445
// If there was no reportID, then that means the user started this flow from the global + menu
453446
// and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense.
454-
if (iouType === CONST.IOU.TYPE.CREATE && isPaidGroupPolicy(activePolicy) && activePolicy?.isPolicyExpenseChatEnabled && !shouldRestrictUserBillableActions(activePolicy.id)) {
455-
const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id);
447+
const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id);
448+
if (
449+
(!initialTransaction?.participants || initialTransaction?.participants?.at(0)?.reportID === activePolicyExpenseChat?.reportID) &&
450+
iouType === CONST.IOU.TYPE.CREATE &&
451+
isPaidGroupPolicy(activePolicy) &&
452+
activePolicy?.isPolicyExpenseChatEnabled &&
453+
!shouldRestrictUserBillableActions(activePolicy.id)
454+
) {
456455
const setParticipantsPromises = files.map((receiptFile) => setMoneyRequestParticipantsFromReport(receiptFile.transactionID, activePolicyExpenseChat));
457456
Promise.all(setParticipantsPromises).then(() =>
458457
Navigation.navigate(
@@ -465,6 +464,12 @@ function IOURequestStepScan({
465464
),
466465
);
467466
} else {
467+
// If the initial transaction already has the participants selected, then we can skip the participants step and go straight to the confirmation step.
468+
if (initialTransaction?.participants && initialTransaction?.participants.length > 0) {
469+
const setParticipantsPromises = files.map((receiptFile) => setMoneyRequestParticipants(receiptFile.transactionID, initialTransaction?.participants));
470+
Promise.all(setParticipantsPromises).then(() => navigateToConfirmationPage(false, initialTransaction?.reportID));
471+
return;
472+
}
468473
navigateToParticipantPage(iouType, initialTransactionID, reportID);
469474
}
470475
},

src/pages/iou/request/step/IOURequestStepScan/index.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function IOURequestStepScan({
317317
}, [backTo]);
318318

319319
const navigateToConfirmationPage = useCallback(
320-
(isTestTransaction = false, reportIDParam: string | undefined = undefined) => {
320+
(shouldNavigateToSubmit = false, reportIDParam: string | undefined = undefined) => {
321321
switch (iouType) {
322322
case CONST.IOU.TYPE.REQUEST:
323323
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, initialTransactionID, reportID, backToReport));
@@ -329,7 +329,7 @@ function IOURequestStepScan({
329329
Navigation.navigate(
330330
ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
331331
CONST.IOU.ACTION.CREATE,
332-
isTestTransaction ? CONST.IOU.TYPE.SUBMIT : iouType,
332+
shouldNavigateToSubmit ? CONST.IOU.TYPE.SUBMIT : iouType,
333333
initialTransactionID,
334334
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
335335
reportIDParam || reportID,
@@ -503,17 +503,16 @@ function IOURequestStepScan({
503503
return;
504504
}
505505

506-
// If the initial transaction already has the participants selected, then we can skip the participants step and go straight to the confirmation step.
507-
if (initialTransaction?.participants && initialTransaction?.participants.length > 0) {
508-
const setParticipantsPromises = files.map((receiptFile) => setMoneyRequestParticipants(receiptFile.transactionID, initialTransaction?.participants));
509-
Promise.all(setParticipantsPromises).then(() => navigateToConfirmationPage(false, initialTransaction?.reportID));
510-
return;
511-
}
512-
513506
// If there was no reportID, then that means the user started this flow from the global + menu
514507
// and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense.
515-
if (iouType === CONST.IOU.TYPE.CREATE && isPaidGroupPolicy(activePolicy) && activePolicy?.isPolicyExpenseChatEnabled && !shouldRestrictUserBillableActions(activePolicy.id)) {
516-
const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id);
508+
const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id);
509+
if (
510+
(!initialTransaction?.participants || initialTransaction?.participants?.at(0)?.reportID === activePolicyExpenseChat?.reportID) &&
511+
iouType === CONST.IOU.TYPE.CREATE &&
512+
isPaidGroupPolicy(activePolicy) &&
513+
activePolicy?.isPolicyExpenseChatEnabled &&
514+
!shouldRestrictUserBillableActions(activePolicy.id)
515+
) {
517516
const setParticipantsPromises = files.map((receiptFile) => setMoneyRequestParticipantsFromReport(receiptFile.transactionID, activePolicyExpenseChat));
518517
Promise.all(setParticipantsPromises).then(() =>
519518
Navigation.navigate(
@@ -526,6 +525,12 @@ function IOURequestStepScan({
526525
),
527526
);
528527
} else {
528+
// If the initial transaction already has the participants selected, then we can skip the participants step and go straight to the confirmation step.
529+
if (initialTransaction?.participants && initialTransaction?.participants.length > 0) {
530+
const setParticipantsPromises = files.map((receiptFile) => setMoneyRequestParticipants(receiptFile.transactionID, initialTransaction?.participants));
531+
Promise.all(setParticipantsPromises).then(() => navigateToConfirmationPage(true, initialTransaction?.reportID));
532+
return;
533+
}
529534
navigateToParticipantPage(iouType, initialTransactionID, reportID);
530535
}
531536
},

0 commit comments

Comments
 (0)