Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
f4d6c84
Skip the amopunt and participants steps to match the new UI.
ChavdaSachin Apr 14, 2026
0834d60
Show an error when amount field is empty
ChavdaSachin Apr 17, 2026
8560ceb
Show an error when amount field is empty
ChavdaSachin Apr 17, 2026
d6bef7e
Enable keyboard avoiding view in favour of new inline input UI.
ChavdaSachin Apr 17, 2026
3026c0b
Show an error when amount field is empty
ChavdaSachin Apr 17, 2026
f8e7fb6
Place Merchant field next to the Amount field
ChavdaSachin Apr 17, 2026
23b98fc
Refine description saving logic to avoid clearing blank spoace and ne…
ChavdaSachin Apr 17, 2026
eb2b91d
Show an error when amount field is empty
ChavdaSachin Apr 17, 2026
302b665
Hide suplicate header in embaded view.
ChavdaSachin Apr 17, 2026
feba233
Prettier
ChavdaSachin Apr 17, 2026
f780d24
Merge remote-tracking branch 'upstream/main' into Manual-expense-flow…
ChavdaSachin Apr 23, 2026
b0e14bd
Refactor manual expense flow UI components and logic for improved cla…
ChavdaSachin Apr 24, 2026
2f045a1
Merge remote-tracking branch 'upstream/main' into Manual-expense-flow…
ChavdaSachin Apr 24, 2026
5fd1a5a
Merge remote-tracking branch 'upstream/main' into Manual-expense-flow…
ChavdaSachin Apr 27, 2026
30211c7
Add participantPicker to new flow to make it one step process
ChavdaSachin Apr 27, 2026
2bf1d2e
Prettier, lint
ChavdaSachin Apr 27, 2026
bdcc8df
Remove the redundant tests
ChavdaSachin Apr 28, 2026
ea0e2b1
Update the error guard
ChavdaSachin Apr 28, 2026
70aa4cd
Prettier
ChavdaSachin Apr 28, 2026
5702292
Refactor split changes
ChavdaSachin Apr 28, 2026
dcb3024
Merge remote-tracking branch 'upstream/main' into Manual-expense-flow…
ChavdaSachin Apr 28, 2026
5b084d8
LInt
ChavdaSachin Apr 28, 2026
bf94b71
Merge remote-tracking branch 'upstream/main' into Manual-expense-flow…
ChavdaSachin Apr 28, 2026
f40ca76
Prettier
ChavdaSachin Apr 28, 2026
c94fb14
Auto focus the amount field
ChavdaSachin Apr 28, 2026
702dfad
lint
ChavdaSachin Apr 28, 2026
290e742
Merge remote-tracking branch 'upstream/main' into Manual-expense-flow…
ChavdaSachin Apr 29, 2026
db62613
Default merchant value is displayed for older flow
ChavdaSachin Apr 29, 2026
ea05fa8
Elivate the participants picker
ChavdaSachin May 1, 2026
4565001
fix: Participants picker renders selected items twice
ChavdaSachin May 1, 2026
07b8c7a
Refactor drag and drop provider disabling condition
ChavdaSachin May 1, 2026
3872732
Show error for empty amount field
ChavdaSachin May 1, 2026
288dc6b
Auto focus the amount field for the new flow
ChavdaSachin May 1, 2026
6607c27
Merge remote-tracking branch 'upstream/main' into Manual-expense-flow…
ChavdaSachin May 4, 2026
458d3b5
prettier
ChavdaSachin May 4, 2026
89ab9ed
Lint
ChavdaSachin May 4, 2026
a6aa951
Lint
ChavdaSachin May 4, 2026
e6c0c5d
lint
ChavdaSachin May 4, 2026
7c67b6f
Show field required error when user clears the amount field and tries…
ChavdaSachin May 6, 2026
f661c16
Adjust the field to add new line on 'shift + Enter' and submit on 'En…
ChavdaSachin May 6, 2026
a5b8e74
Merge remote-tracking branch 'upstream/main' into Manual-expense-flow…
ChavdaSachin May 6, 2026
e8621dc
Move the merchant field above the description field
ChavdaSachin May 6, 2026
4a13c19
Show receipt empty state for new flow
ChavdaSachin May 6, 2026
b4aaceb
lint
ChavdaSachin May 7, 2026
454305f
fix tests
ChavdaSachin May 7, 2026
e1593fd
fix participantsPicker flicker
ChavdaSachin May 12, 2026
5f4e503
improve TS structure
ChavdaSachin May 12, 2026
dbf1a52
Merge remote-tracking branch 'upstream/main' into Manual-expense-flow…
ChavdaSachin May 12, 2026
c66718e
lint
ChavdaSachin May 12, 2026
b1961af
fix tests
ChavdaSachin May 12, 2026
734a1a4
lint
ChavdaSachin May 12, 2026
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
54 changes: 48 additions & 6 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {useFocusEffect, useIsFocused} from '@react-navigation/native';
import React, {useCallback, useEffect, useRef, useState} from 'react';
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
// eslint-disable-next-line no-restricted-imports
import {InteractionManager, View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useIsInLandscapeMode from '@hooks/useIsInLandscapeMode';
import useLocalize from '@hooks/useLocalize';
import {MouseProvider} from '@hooks/useMouseContext';
import usePermissions from '@hooks/usePermissions';
import usePolicyForMovingExpenses from '@hooks/usePolicyForMovingExpenses';
Expand Down Expand Up @@ -64,6 +65,9 @@ type MoneyRequestConfirmationListProps = {
/** Callback to inform parent modal of success */
onConfirm?: (selectedParticipants: Participant[]) => void;

/** When set, used in the new manual expense flow to open the parent-owned participant picker instead of navigating away */
onOpenParticipantPicker?: () => void;

/** Callback to parent modal to pay someone */
onSendMoney?: (paymentMethod: PaymentMethodType | undefined) => void;

Expand Down Expand Up @@ -164,6 +168,7 @@ function MoneyRequestConfirmationList({
transaction,
onSendMoney,
onConfirm,
onOpenParticipantPicker,
iouType = CONST.IOU.TYPE.SUBMIT,
isOdometerDistanceRequest = false,
isLoadingReceipt = false,
Expand Down Expand Up @@ -204,6 +209,7 @@ function MoneyRequestConfirmationList({
const {isDelegateAccessRestricted} = useDelegateNoAccessState();
const {showDelegateNoAccessModal} = useDelegateNoAccessActions();
const isInLandscapeMode = useIsInLandscapeMode();
const {translate} = useLocalize();

const {isTestReceipt, shouldShowProductTrainingTooltip, renderProductTrainingTooltip} = useReceiptTraining({
transaction,
Expand Down Expand Up @@ -257,7 +263,6 @@ function MoneyRequestConfirmationList({
iouCurrencyCode,
});

// A flag for showing the categories field
const shouldShowCategories = isTrackExpense
? !policy || shouldSelectPolicy || !!iouCategory || hasEnabledOptions(Object.values(policyCategories ?? {}))
: (isPolicyExpenseChat || isTypeInvoice) && (!!iouCategory || hasEnabledOptions(Object.values(policyCategories ?? {})));
Expand Down Expand Up @@ -293,6 +298,9 @@ function MoneyRequestConfirmationList({
prevSubRates,
});

const isManualRequest = transaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.MANUAL;
const shouldForceTopEmptySections = isNewManualExpenseFlowEnabled && (iouType === CONST.IOU.TYPE.CREATE || isManualRequest || isScanRequest);

const isFocused = useIsFocused();

const [didConfirm, setDidConfirm] = useState(isConfirmed);
Expand All @@ -307,7 +315,7 @@ function MoneyRequestConfirmationList({
const isTypeSplit = iouType === CONST.IOU.TYPE.SPLIT;
const shouldShowReadOnlySplits = isPolicyExpenseChat || isReadOnly || isScanRequest;

const {formError, setFormError, clearFormErrors, shouldDisplayFieldError, isMerchantEmpty, isMerchantRequired, errorMessage} = useFormErrorManagement({
const {formError, setFormError, clearFormErrors, shouldDisplayFieldError, isMerchantEmpty, isMerchantFieldValid, isMerchantRequired, errorMessage} = useFormErrorManagement({
transaction,
transactionReport,
iouMerchant,
Expand Down Expand Up @@ -360,6 +368,24 @@ function MoneyRequestConfirmationList({
const selectedParticipants = selectedParticipantsProp.filter((participant) => participant.selected);
const payeePersonalDetails = payeePersonalDetailsProp ?? currentUserPersonalDetails;

const participantRowErrors = useMemo(() => {
if (formError !== 'iou.error.noParticipantSelected' && formError !== 'violations.missingAttendees') {
return undefined;
}
return {participants: translate(formError)};
}, [formError, translate]);

useEffect(() => {
if (selectedParticipants.length === 0) {
return;
}
clearFormErrors(['iou.error.noParticipantSelected']);
}, [selectedParticipants.length, clearFormErrors]);

const dismissParticipantRowError = useCallback(() => {
clearFormErrors(['iou.error.noParticipantSelected', 'violations.missingAttendees']);
}, [clearFormErrors]);

const {splitParticipants, getSplitSectionHeader} = useSplitParticipants({
isTypeSplit,
shouldShowReadOnlySplits,
Expand All @@ -375,6 +401,8 @@ function MoneyRequestConfirmationList({
const sections = useConfirmationSections({
isTypeSplit,
shouldHideToSection,
shouldForceTopEmptySections,
participantRowErrors,
canEditParticipant,
payeePersonalDetails,
splitParticipants,
Expand All @@ -390,8 +418,13 @@ function MoneyRequestConfirmationList({
return;
}

if (isNewManualExpenseFlowEnabled) {
onOpenParticipantPicker?.();
return;
}

const newIOUType = iouType === CONST.IOU.TYPE.SUBMIT || iouType === CONST.IOU.TYPE.TRACK ? CONST.IOU.TYPE.CREATE : iouType;
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(newIOUType, transactionID, transaction.reportID, Navigation.getActiveRoute(), action));
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(newIOUType, transactionID, transaction?.reportID, Navigation.getActiveRoute(), action));
};

const {validate} = useConfirmationValidation({
Expand All @@ -412,15 +445,16 @@ function MoneyRequestConfirmationList({
currentUserPersonalDetails,
isEditingSplitBill,
isMerchantRequired,
isMerchantFieldValid,
isMerchantEmpty,
shouldDisplayFieldError,
shouldShowTax,
isDistanceRequest,
isDistanceRequestWithPendingRoute,
isPerDiemRequest,
isTimeRequest,
isNewManualExpenseFlowEnabled,
routeError,
isNewManualExpenseFlowEnabled,
});

const confirm = buildConfirmAction({
Expand All @@ -443,13 +477,17 @@ function MoneyRequestConfirmationList({
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
useFocusEffect(
useCallback(() => {
// Blurring the active element after transition fights AmountField focus in the new manual flow (RHP reopen).
if (isNewManualExpenseFlowEnabled) {
return undefined;
}
focusTimeoutRef.current = setTimeout(() => {
InteractionManager.runAfterInteractions(() => {
blurActiveElement();
});
}, CONST.ANIMATED_TRANSITION);
return () => focusTimeoutRef.current && clearTimeout(focusTimeoutRef.current);
}, []),
}, [isNewManualExpenseFlowEnabled]),
);

const isCompactMode = !showMoreFields && isScanRequest && !isInLandscapeMode;
Expand Down Expand Up @@ -489,6 +527,8 @@ function MoneyRequestConfirmationList({
formattedAmount={formattedAmount}
formattedAmountPerAttendee={formattedAmountPerAttendee}
formError={formError}
clearFormErrors={clearFormErrors}
setFormError={setFormError}
hasRoute={hasRoute}
iouType={iouType}
isCategoryRequired={isCategoryRequired}
Expand Down Expand Up @@ -532,6 +572,7 @@ function MoneyRequestConfirmationList({
isDescriptionRequired={isDescriptionRequired}
showMoreFields={showMoreFields}
setShowMoreFields={setShowMoreFields}
onSubmitForm={confirm}
/>
</View>
);
Expand Down Expand Up @@ -603,6 +644,7 @@ function MoneyRequestConfirmationList({
sections={sections}
ListItem={BareUserListItem}
onSelectRow={navigateToParticipantPage}
onDismissError={dismissParticipantRowError}
shouldSingleExecuteRowSelect
shouldPreventDefaultFocusOnSelectRow
shouldShowListEmptyContent={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function buildConfirmAction({
onConfirm,
onSendMoney,
}: BuildConfirmActionParams) {
return ({paymentType: paymentMethod}: PaymentActionParams) => {
return ({paymentType: paymentMethod}: PaymentActionParams = {}) => {
// Routing short-circuit: invoices without company info go to the company info step before we validate anything.
if (iouType === CONST.IOU.TYPE.INVOICE && !hasInvoicingDetails(policy) && transactionID && !routeError) {
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_COMPANY_INFO.getRoute(iouType, transactionID, reportID, Navigation.getActiveRoute()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ type UseConfirmationSectionsParams = {
/** Whether the "to" section should be hidden (used when adding directly to a report) */
shouldHideToSection: boolean;

/**
* When true with `shouldHideToSection`, still render the "To" section (e.g. new manual flow so the user can open the participant picker).
*/
shouldForceTopEmptySections?: boolean;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: Can we use a clearer name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be removed when removing the beta


/** Row-level errors for the participant section (e.g. missing recipient / attendees), shown on the list row */
participantRowErrors?: Record<string, string>;

/** Whether participant rows should be interactive (allow editing the recipient) */
canEditParticipant: boolean;

Expand Down Expand Up @@ -44,6 +52,8 @@ type UseConfirmationSectionsParams = {
function useConfirmationSections({
isTypeSplit,
shouldHideToSection,
shouldForceTopEmptySections = false,
participantRowErrors,
canEditParticipant,
payeePersonalDetails,
splitParticipants,
Expand All @@ -67,18 +77,31 @@ function useConfirmationSections({
},
);
// When adding an expense from within a report, hide the "To:" section since the destination is already the current report
} else if (!shouldHideToSection) {
const formattedSelectedParticipants = selectedParticipants.map((participant) => ({
...participant,
isSelected: false,
keyForList: `${participant.keyForList ?? participant.accountID ?? participant.reportID}`,
isInteractive: canEditParticipant,
shouldShowRightCaret: canEditParticipant,
}));
} else if (!shouldHideToSection || shouldForceTopEmptySections) {
const participantRows =
selectedParticipants.length > 0
? selectedParticipants.map((participant) => ({
...participant,
isSelected: false,
keyForList: `${participant.keyForList ?? participant.accountID ?? participant.reportID}`,
isInteractive: canEditParticipant,
shouldShowRightCaret: canEditParticipant,
...(participantRowErrors ? {errors: participantRowErrors} : {}),
}))
: [
{
keyForList: 'empty-participant-option',
text: translate('iou.chooseRecipient'),
isInteractive: canEditParticipant,
shouldShowRightCaret: canEditParticipant,
isBold: false,
...(participantRowErrors ? {errors: participantRowErrors} : {}),
},
];

options.push({
title: translate('common.to'),
data: formattedSelectedParticipants,
title: selectedParticipants.length > 0 ? translate('common.to') : undefined,
data: participantRows,
sectionIndex: 0,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {getTagLists as getTagListsFn} from '@libs/PolicyUtils';
import {isAttendeeTrackingEnabled} from '@libs/PolicyUtils';
import {hasEnabledTags, hasMatchingTag} from '@libs/TagsOptionsListUtils';
import {isValidTimeExpenseAmount} from '@libs/TimeTrackingUtils';
import {areRequiredFieldsEmpty, getTag, hasTaxRateWithMatchingValue, isMerchantMissing} from '@libs/TransactionUtils';
import {areRequiredFieldsEmpty, getTag, hasTaxRateWithMatchingValue, isMerchantMissing, isScanRequest as isScanRequestUtil} from '@libs/TransactionUtils';
import {isValidInputLength} from '@libs/ValidationUtils';
import type {IOUType} from '@src/CONST';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -71,10 +71,13 @@ type UseConfirmationValidationParams = {
/** Whether the merchant field is required for this flow */
isMerchantRequired: boolean | undefined;

/** Whether the merchant field is currently empty / partial */
/** Whether the merchant value passes full validation (length, required, disallowed values) */
isMerchantFieldValid: boolean;

/** Whether the merchant field is empty / partial (from {@link useFormErrorManagement}) */
isMerchantEmpty: boolean;

/** Whether per-field errors should be shown */
/** When editing a split bill, whether per-field errors should be shown (SmartScan failure paths) */
shouldDisplayFieldError: boolean;

/** Whether the tax section is enabled for this policy */
Expand All @@ -92,11 +95,11 @@ type UseConfirmationValidationParams = {
/** Whether the transaction is a time-tracking request */
isTimeRequest: boolean;

/** Whether the new manual expense flow beta is enabled */
isNewManualExpenseFlowEnabled: boolean;

/** Truthy when the route to the confirmation page has a known error */
routeError: string | null | undefined;

/** Whether the new manual expense flow is enabled */
isNewManualExpenseFlowEnabled: boolean;
};

/**
Expand Down Expand Up @@ -131,15 +134,16 @@ function useConfirmationValidation({
currentUserPersonalDetails,
isEditingSplitBill,
isMerchantRequired,
isMerchantFieldValid,
isMerchantEmpty,
shouldDisplayFieldError,
shouldShowTax,
isDistanceRequest,
isDistanceRequestWithPendingRoute,
isPerDiemRequest,
isTimeRequest,
isNewManualExpenseFlowEnabled,
routeError,
isNewManualExpenseFlowEnabled,
}: UseConfirmationValidationParams): {validate: (paymentType?: PaymentMethodType) => ValidationResult | null} {
const {getCurrencyDecimals} = useCurrencyListActions();
const selectedParticipantsCount = selectedParticipants.length;
Expand All @@ -152,21 +156,30 @@ function useConfirmationValidation({
return {errorKey: 'iou.error.noParticipantSelected'};
}

const amountForValidation = iouAmount;
const isAmountMissingForManualFlow = amountForValidation === null || amountForValidation === undefined;
const firstParticipant = transaction?.participants?.at(0);
const isP2P = !!(firstParticipant?.accountID && !firstParticipant?.isPolicyExpenseChat);

if (iouType !== CONST.IOU.TYPE.PAY && isNewManualExpenseFlowEnabled && isAmountMissingForManualFlow) {
// P2P manual submit: $0 is invalid unless scan/time/distance (same guard as legacy inline confirm).
if (iouType !== CONST.IOU.TYPE.PAY && !isScanRequestUtil(transaction) && !isTimeRequest && !isDistanceRequest && iouAmount === 0 && isP2P) {
return {errorKey: 'common.error.invalidAmount'};
}

if (isNewManualExpenseFlowEnabled && !transaction?.isAmountSet) {
return {errorKey: 'common.error.fieldRequired'};
}
const merchantValue = iouMerchant ?? '';
const {isValid: isMerchantLengthValid} = isValidInputLength(merchantValue, CONST.MERCHANT_NAME_MAX_BYTES);

if (!isMerchantLengthValid) {
return {errorKey: 'iou.error.invalidMerchant'};
}

if (!isEditingSplitBill && isMerchantRequired && (isMerchantEmpty || (shouldDisplayFieldError && isMerchantMissing(transaction)))) {
if (isMerchantRequired) {
if (!isEditingSplitBill && !isMerchantFieldValid) {
return {errorKey: 'iou.error.invalidMerchant'};
}
if (isEditingSplitBill && (isMerchantEmpty || (shouldDisplayFieldError && isMerchantMissing(transaction)))) {
return {errorKey: 'iou.error.invalidMerchant'};
}
} else if (transaction?.isMerchantSet && !isMerchantFieldValid) {
return {errorKey: 'iou.error.invalidMerchant'};
}

Expand Down Expand Up @@ -252,4 +265,4 @@ function useConfirmationValidation({
}

export default useConfirmationValidation;
export type {ValidationResult};
export type {ValidationResult, UseConfirmationValidationParams};
Loading
Loading