Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix create expense flow regression #56638

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ const ROUTES = {
},
MONEY_REQUEST_STEP_PARTICIPANTS: {
route: ':action/:iouType/participants/:transactionID/:reportID',
getRoute: (iouType: IOUType, transactionID: string | undefined, reportID: string, backTo = '', action: IOUAction = 'create') =>
getRoute: (iouType: IOUType, transactionID: string | undefined, reportID: string | undefined, backTo = '', action: IOUAction = 'create') =>
getUrlWithBackToParam(`${action as string}/${iouType as string}/participants/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_SPLIT_PAYER: {
Expand Down
28 changes: 8 additions & 20 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {validateAmount} from '@libs/MoneyRequestUtils';
import Navigation from '@libs/Navigation/Navigation';
import {getIOUConfirmationOptionsFromPayeePersonalDetail, hasEnabledOptions} from '@libs/OptionsListUtils';
import {getDistanceRateCustomUnitRate, getTagLists, isTaxTrackingEnabled} from '@libs/PolicyUtils';
import {isDraftReport, isOptimisticPersonalDetail} from '@libs/ReportUtils';
import type {OptionData} from '@libs/ReportUtils';
import playSound, {SOUNDS} from '@libs/Sound';
import {
Expand Down Expand Up @@ -230,6 +229,7 @@ function MoneyRequestConfirmationList({
const isTypeTrackExpense = iouType === CONST.IOU.TYPE.TRACK;
const isTypeInvoice = iouType === CONST.IOU.TYPE.INVOICE;
const isScanRequest = useMemo(() => isScanRequestUtil(transaction), [transaction]);
const isCreateExpenseFlow = transaction?.isFromGlobalCreate && !isPerDiemRequest;

const transactionID = transaction?.transactionID;
const customUnitRateID = getRateID(transaction);
Expand Down Expand Up @@ -339,18 +339,6 @@ function MoneyRequestConfirmationList({

const isCategoryRequired = !!policy?.requiresCategory;

const shouldDisableParticipant = (participant: Participant): boolean => {
if (isDraftReport(participant.reportID)) {
return true;
}

if (!participant.isInvoiceRoom && !participant.isPolicyExpenseChat && !participant.isSelfDM && isOptimisticPersonalDetail(participant.accountID ?? CONST.DEFAULT_NUMBER_ID)) {
return true;
}

return false;
};

useEffect(() => {
if (shouldDisplayFieldError && didConfirmSplit) {
setFormError('iou.error.genericSmartscanFailureMessage');
Expand Down Expand Up @@ -596,7 +584,7 @@ function MoneyRequestConfirmationList({
return {
...participantOption,
isSelected: false,
isInteractive: !shouldDisableParticipant(participantOption),
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
isInteractive: false,
rightElement: (
<View style={[styles.flexWrap, styles.pl2]}>
<Text style={[styles.textLabel]}>{amount ? convertToDisplayString(amount, iouCurrencyCode) : ''}</Text>
Expand All @@ -613,7 +601,7 @@ function MoneyRequestConfirmationList({
...participantOption,
tabIndex: -1,
isSelected: false,
isInteractive: !shouldDisableParticipant(participantOption),
isInteractive: false,
rightElement: (
<MoneyRequestAmountInput
autoGrow={false}
Expand Down Expand Up @@ -719,8 +707,8 @@ function MoneyRequestConfirmationList({
const formattedSelectedParticipants = selectedParticipants.map((participant) => ({
...participant,
isSelected: false,
isInteractive: transaction?.isFromGlobalCreate,
shouldShowRightIcon: transaction?.isFromGlobalCreate,
isInteractive: isCreateExpenseFlow,
shouldShowRightIcon: isCreateExpenseFlow,
}));
options.push({
title: translate('common.to'),
Expand All @@ -730,7 +718,7 @@ function MoneyRequestConfirmationList({
}

return options;
}, [isTypeSplit, translate, payeePersonalDetails, getSplitSectionHeader, splitParticipants, selectedParticipants, transaction?.isFromGlobalCreate]);
}, [isTypeSplit, translate, payeePersonalDetails, getSplitSectionHeader, splitParticipants, selectedParticipants, isCreateExpenseFlow]);
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
if (!isDistanceRequest || (isMovingTransactionFromTrackExpense && !isPolicyExpenseChat) || !transactionID) {
Expand Down Expand Up @@ -805,11 +793,11 @@ function MoneyRequestConfirmationList({
* Navigate to the participant step
*/
const navigateToParticipantPage = () => {
if (!transaction?.isFromGlobalCreate) {
if (!isCreateExpenseFlow) {
return;
}

Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID));
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.CREATE, transactionID, transaction.reportID));
};

/**
Expand Down
2 changes: 2 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ type PayeePersonalDetails = {
login: string;
accountID: number;
keyForList: string;
isInteractive: boolean;
};

type SectionBase = {
Expand Down Expand Up @@ -1627,6 +1628,7 @@ function getIOUConfirmationOptionsFromPayeePersonalDetail(personalDetail: OnyxEn
login: personalDetail?.login ?? '',
accountID: personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID,
keyForList: String(personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID),
isInteractive: false,
};
}

Expand Down
3 changes: 3 additions & 0 deletions src/pages/iou/request/step/IOURequestStepDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
createDistanceRequest,
getIOURequestPolicyID,
resetSplitShares,
setCustomUnitRateID,
setMoneyRequestAmount,
setMoneyRequestMerchant,
setMoneyRequestParticipantsFromReport,
Expand Down Expand Up @@ -379,6 +380,8 @@ function IOURequestStepDistance({
if (iouType === CONST.IOU.TYPE.CREATE && isPaidGroupPolicy(activePolicy) && activePolicy?.isPolicyExpenseChatEnabled) {
const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id);
setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat);
const rateID = DistanceRequestUtils.getCustomUnitRateID(activePolicyExpenseChat?.reportID);
setCustomUnitRateID(transactionID, rateID);
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
CONST.IOU.ACTION.CREATE,
Expand Down
Loading