Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
cbb8e4a
fix: skip participant picker for group workspace sharing
nabi-ebrahimi Sep 3, 2026
46df1db
Merge branch 'main' into fix/group-workspace-share-sheet
nabi-ebrahimi Sep 4, 2026
fa6e03c
fix(share): wait for destination data before auto-navigation
nabi-ebrahimi Sep 4, 2026
66e11b9
Merge branch 'main' into fix/group-workspace-share-sheet
nabi-ebrahimi Sep 10, 2026
1ffd460
fix: honor disabled auto-reporting in share default destination
nabi-ebrahimi Sep 10, 2026
5b5dc07
fix: avoid nested ternary in share destination selection
nabi-ebrahimi Sep 10, 2026
1cc1097
docs: clarify default policy eligibility in share submit flow
nabi-ebrahimi Sep 15, 2026
84ed70e
fix: preserve auto-selected share destination on back navigation
nabi-ebrahimi Sep 15, 2026
c988968
fix: only auto-navigate share submit to auto-reporting workspace
nabi-ebrahimi Sep 15, 2026
8228e5d
fix: preserve draft transaction fields on share participant edit
nabi-ebrahimi Sep 16, 2026
58d4c45
Fix Share Submit flow: auto-navigation, draft preservation, pre-mount…
nabi-ebrahimi Sep 16, 2026
73a295d
fix: prevent duplicate pre-mount buffers and cache Onyx selectors
nabi-ebrahimi Sep 19, 2026
5761384
Merge branch 'main' into fix/group-workspace-share-sheet
nabi-ebrahimi Sep 22, 2026
251bc78
fix: resolve pre-mount buffer CI failures
nabi-ebrahimi Sep 22, 2026
ec6a244
fix: reset policy fields when changing share destination
nabi-ebrahimi Sep 25, 2026
46b7989
Merge branch 'main' into fix/group-workspace-share-sheet
nabi-ebrahimi Sep 28, 2026
b197eb9
fix: preserve replaced receipt when changing share destination
nabi-ebrahimi Oct 2, 2026
4e9a129
Merge branch 'main' into fix/group-workspace-share-sheet
nabi-ebrahimi Oct 2, 2026
43a8879
Fix pre-mount cleanup when changing share destination
nabi-ebrahimi Oct 2, 2026
f67d718
Fix share destination readiness and remove unrelated changes
nabi-ebrahimi Oct 2, 2026
26d62f2
Fix stale attendees when changing share destination
nabi-ebrahimi Oct 14, 2026
d675148
fix: preserve expense fields when reselecting the same workspace
nabi-ebrahimi Oct 14, 2026
6c4067d
fix: resolve share destination validation failures
nabi-ebrahimi Oct 14, 2026
3522c0e
Merge branch 'main' into fix/group-workspace-share-sheet
nabi-ebrahimi Oct 16, 2026
8067e2f
Merge branch 'main' into fix/group-workspace-share-sheet
nabi-ebrahimi Oct 17, 2026
f4f1fe0
Fix report selection reset when reselecting workspace
nabi-ebrahimi Oct 19, 2026
29b1f28
Preserve fields and apply defaults when changing share destination
nabi-ebrahimi Oct 19, 2026
2a4c8a7
Allow default workspace navigation without auto-reporting
nabi-ebrahimi Oct 20, 2026
0e607eb
Wait for default expense chat hydration before navigation
nabi-ebrahimi Oct 20, 2026
5da77a0
Refactor preferred policy mock to include loading state in tests
nabi-ebrahimi Oct 20, 2026
cceeb29
Fix personal share destination identity
nabi-ebrahimi Oct 21, 2026
3361464
Prevent stale workspace billable defaults in P2P shares
nabi-ebrahimi Oct 21, 2026
82d1563
Document share flow tests with Given When Then
nabi-ebrahimi Oct 21, 2026
9285c82
Fix confirmation field focus after changing workspace
nabi-ebrahimi Oct 26, 2026
a02a06f
Fix stale recipient in automatic share navigation
nabi-ebrahimi Oct 26, 2026
3e38ffa
Fix policy field cleanup for non-workspace destinations
nabi-ebrahimi Oct 26, 2026
21045cc
Fix missing expense chat fallback in Share flow
nabi-ebrahimi Oct 26, 2026
d1596de
Merge branch 'main' into fix/group-workspace-share-sheet
nabi-ebrahimi Oct 26, 2026
c1b241e
Fix focus tracking lint violation
nabi-ebrahimi Oct 26, 2026
390b309
Fix Share confirmation navigation mocks
nabi-ebrahimi Oct 26, 2026
aeddcd3
Fix P2P destination selection for negative shared expenses
nabi-ebrahimi Oct 26, 2026
567813e
Merge branch 'main' into fix/group-workspace-share-sheet
nabi-ebrahimi Oct 29, 2026
5189824
Fix Share flow lint and TypeScript failures
nabi-ebrahimi Oct 31, 2026
b610a07
Merge branch 'main' into fix/group-workspace-share-sheet
nabi-ebrahimi Nov 5, 2026
bcb0648
Allow Self DM for negative shared expenses
nabi-ebrahimi Nov 7, 2026
f7aba47
Apply workspace defaults after Share draft initialization
nabi-ebrahimi Nov 7, 2026
f4715ff
Fix P2P destination selection indicator after returning to picker
nabi-ebrahimi Nov 9, 2026
392462e
Keep Share destination editable for Self DM
nabi-ebrahimi Nov 9, 2026
ca690af
Merge branch 'main' into fix/group-workspace-share-sheet
nabi-ebrahimi Nov 9, 2026
44724cf
Fix SubmitDetailsPage test mock hoisting failure
nabi-ebrahimi Nov 9, 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
111 changes: 111 additions & 0 deletions src/components/MoneyRequestConfirmationList/focusManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import CONST from '@src/CONST';

import type {RefObject} from 'react';

import {useEffect, useSyncExternalStore} from 'react';

type ConfirmationField = 'amount' | 'description' | 'merchant' | 'taxAmount';
type FocusableInput = {focus: () => void};

const lastFocusedFieldByTransaction = new Map<string, ConfirmationField>();
const pendingFieldByTransaction = new Map<string, ConfirmationField>();
const trackedTransactionIDs = new Set<string>();
const listeners = new Set<() => void>();
let focusRestoreRevision = 0;

function subscribeToFocusRestore(callback: () => void) {
listeners.add(callback);
return () => {
listeners.delete(callback);
};
}

function getFocusRestoreRevision() {
return focusRestoreRevision;
}

function notifyConfirmationScreenFocused(transactionID: string | undefined) {
if (!transactionID || !pendingFieldByTransaction.has(transactionID)) {
return;
}
focusRestoreRevision += 1;
for (const listener of listeners) {
listener();
}
}

function enableConfirmationFocusTracking(transactionID: string | undefined) {
if (!transactionID) {
return;
}
trackedTransactionIDs.add(transactionID);
}

// Focus is UI-only state, so keep it in memory and scope it to the draft transaction instead of persisting it in Onyx.
function recordFocusedConfirmationField(transactionID: string | undefined, field: ConfirmationField) {
if (!transactionID || !trackedTransactionIDs.has(transactionID)) {
return;
}
lastFocusedFieldByTransaction.set(transactionID, field);
}

function prepareConfirmationFocusRestore(transactionID: string | undefined) {
if (!transactionID || !trackedTransactionIDs.has(transactionID)) {
return;
}
const lastFocusedField = lastFocusedFieldByTransaction.get(transactionID);
if (lastFocusedField) {
pendingFieldByTransaction.set(transactionID, lastFocusedField);
}
}

function hasPendingConfirmationFocusRestore(transactionID: string | undefined, field?: ConfirmationField) {
if (!transactionID) {
return false;
}
const pendingField = pendingFieldByTransaction.get(transactionID);
return field ? pendingField === field : pendingField !== undefined;
}

function clearConfirmationFocusState() {
lastFocusedFieldByTransaction.clear();
pendingFieldByTransaction.clear();
trackedTransactionIDs.clear();
}

// The destination selection remounts the confirmation route. Defer until its transition completes so the restored
// input is attached and can open the keyboard reliably on native platforms.
function useRestoreConfirmationFieldFocus<T extends FocusableInput>(transactionID: string | undefined, field: ConfirmationField, inputRef: RefObject<T | null>) {
const revision = useSyncExternalStore(subscribeToFocusRestore, getFocusRestoreRevision, getFocusRestoreRevision);
const shouldRestoreFocus = hasPendingConfirmationFocusRestore(transactionID, field);

useEffect(() => {
if (!shouldRestoreFocus) {
return;
}

const timeout = setTimeout(() => {
if (!inputRef.current || !hasPendingConfirmationFocusRestore(transactionID, field)) {
return;
}
inputRef.current.focus();
if (transactionID) {
pendingFieldByTransaction.delete(transactionID);
}
}, CONST.ANIMATED_TRANSITION);

return () => clearTimeout(timeout);
}, [field, inputRef, revision, shouldRestoreFocus, transactionID]);

return shouldRestoreFocus;
}

export {
clearConfirmationFocusState,
enableConfirmationFocusTracking,
hasPendingConfirmationFocusRestore,
notifyConfirmationScreenFocused,
prepareConfirmationFocusRestore,
recordFocusedConfirmationField,
useRestoreConfirmationFieldFocus,
};
3 changes: 3 additions & 0 deletions src/components/MoneyRequestConfirmationList/hooks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ type UseParticipantSectionParams = {
/** Whether the expense is a time expense, whose participant row can never be edited. */
isTimeRequest: boolean;

/** Allows Share Submit to edit its participant without marking the transaction as originating from Global Create. */
shouldAllowParticipantEdit?: boolean;

/** Hide the "To:" section, for an expense added directly to the current report. */
shouldHideToSection: boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function useConfirmationListDataWithPolicy({
showRemoveExpenseConfirmModal,
isPerDiemRequest = false,
isTimeRequest = false,
shouldAllowParticipantEdit,
isDistanceRequest = false,
isScanRequest: isScanRequestProp = false,
distanceState,
Expand Down Expand Up @@ -217,6 +218,7 @@ function useConfirmationListDataWithPolicy({
isTypeInvoice,
isPerDiemRequest,
isTimeRequest,
shouldAllowParticipantEdit,
shouldHideToSection,
shouldShowReadOnlySplits,
selectedParticipantsProp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function useParticipantSection({
isTypeInvoice,
isPerDiemRequest,
isTimeRequest,
shouldAllowParticipantEdit = false,
shouldHideToSection,
shouldShowReadOnlySplits,
selectedParticipantsProp,
Expand Down Expand Up @@ -72,8 +73,8 @@ function useParticipantSection({
currentUserAccountID: currentUserPersonalDetails.accountID,
});

const isFromGlobalCreateAndCanEditParticipant = !!transaction?.isFromGlobalCreate && !isPerDiemRequest && !isTimeRequest;
const canEditParticipant = isFromGlobalCreateAndCanEditParticipant && !isTestReceipt && (!isRestrictedToPreferredPolicy || isTypeInvoice);
const isAllowedToEditParticipant = (!!transaction?.isFromGlobalCreate || shouldAllowParticipantEdit) && !isPerDiemRequest && !isTimeRequest;
const canEditParticipant = isAllowedToEditParticipant && !isTestReceipt && (!isRestrictedToPreferredPolicy || isTypeInvoice);
const isManualRequest = transaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.MANUAL;
const shouldForceTopEmptySections = iouType === CONST.IOU.TYPE.CREATE || isManualRequest || isScanRequest;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import {useConfirmationFields} from '@components/MoneyRequestConfirmationFields/context';
import {hasPendingConfirmationFocusRestore, recordFocusedConfirmationField, useRestoreConfirmationFieldFocus} from '@components/MoneyRequestConfirmationList/focusManager';
import NumberWithSymbolForm from '@components/NumberWithSymbolForm';
import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types';

Expand Down Expand Up @@ -95,6 +96,7 @@ function AmountField({
const amountInputRef = useRef<BaseTextInputRef | null>(null);
const currencyButtonRef = useRef<View>(null);
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
useRestoreConfirmationFieldFocus(transactionID, 'amount', amountInputRef);

const transactionSlice = useTransactionSelector(transactionID, amountSliceSelector);

Expand Down Expand Up @@ -167,7 +169,13 @@ function AmountField({
// `autoFocus` only runs on mount and the RHP often keeps this instance mounted, so focus again when the screen
// regains focus. The timeout waits out the RHP animation.
useEffect(() => {
if (!shouldAutoFocusOnMount || isAmountFieldDisabled || !isScreenFocused || !shouldFocusOnScreenFocusRef.current) {
if (
!shouldAutoFocusOnMount ||
isAmountFieldDisabled ||
!isScreenFocused ||
!shouldFocusOnScreenFocusRef.current ||
(hasPendingConfirmationFocusRestore(transactionID) && !hasPendingConfirmationFocusRestore(transactionID, 'amount'))
) {
return;
}

Expand All @@ -179,7 +187,7 @@ function AmountField({
}
clearTimeout(focusTimeoutRef.current);
};
}, [shouldAutoFocusOnMount, isAmountFieldDisabled, isScreenFocused]);
}, [shouldAutoFocusOnMount, isAmountFieldDisabled, isScreenFocused, transactionID]);

const showCurrencyPicker = () => {
setIsCurrencyPickerVisible(true);
Expand Down Expand Up @@ -385,6 +393,7 @@ function AmountField({
onCurrencyButtonPress={showCurrencyPicker}
currencyButtonRef={currencyButtonRef}
onFocus={() => {
recordFocusedConfirmationField(transactionID, 'amount');
setIsAmountInputFocused(true);
}}
onBlur={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import MentionReportContext from '@components/HTMLEngineProvider/HTMLRenderers/M
import MenuItem from '@components/MenuItem';
import MenuItemFieldHTML from '@components/MenuItem/presets/MenuItemFieldHTML';
import {useConfirmationFields} from '@components/MoneyRequestConfirmationFields/context';
import {recordFocusedConfirmationField, useRestoreConfirmationFieldFocus} from '@components/MoneyRequestConfirmationList/focusManager';
import {ShowContextMenuActionsContext, ShowContextMenuStateContext} from '@components/ShowContextMenuContext';
import TextInput from '@components/TextInput';

Expand Down Expand Up @@ -52,6 +53,8 @@ function DescriptionField({isDescriptionRequired, policy, descriptionHint = ''}:
// Ref on the field's outer container (the bordered box), so scrolling brings the whole field — including its
// top border and label — into view rather than just the inner text area.
const fieldContainerRef = useRef<ComponentRef<typeof View>>(null);
const descriptionInputRef = useRef<ComponentRef<typeof TextInput>>(null);
const shouldRestoreDescriptionFocus = useRestoreConfirmationFieldFocus(transactionID, 'description', descriptionInputRef);

const descriptionState = useTransactionSelector(transactionID, descriptionStateSelector);
const {baseTransaction} = useSplitDraftBaseTransaction(transactionID);
Expand Down Expand Up @@ -146,10 +149,14 @@ function DescriptionField({isDescriptionRequired, policy, descriptionHint = ''}:
style={[styles.mh4, styles.mv2]}
>
<TextInput
ref={descriptionInputRef}
value={iouComment ?? ''}
readOnly={didConfirm}
onChangeText={handleDescriptionInputChange}
onFocus={() => scrollFocusedInputIntoView?.(fieldContainerRef.current)}
onFocus={() => {
recordFocusedConfirmationField(transactionID, 'description');
scrollFocusedInputIntoView?.(fieldContainerRef.current);
}}
submitBehavior={canUseHardwareKeyboard ? 'blurAndSubmit' : 'newline'}
onSubmitEditing={canUseHardwareKeyboard ? onSubmitForm : undefined}
label={translate('common.description')}
Expand All @@ -160,6 +167,7 @@ function DescriptionField({isDescriptionRequired, policy, descriptionHint = ''}:
excludedMarkdownStyles={!policy ? ['mentionReport'] : []}
hint={descriptionHint}
shouldRenderHintAsHTML={!!descriptionHint}
shouldAllowFocusInLandscapeMode={shouldRestoreDescriptionFocus}
/>
</View>
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MenuItem from '@components/MenuItem';
import MenuItemField from '@components/MenuItem/presets/MenuItemField';
import {useConfirmationFields} from '@components/MoneyRequestConfirmationFields/context';
import {recordFocusedConfirmationField, useRestoreConfirmationFieldFocus} from '@components/MoneyRequestConfirmationList/focusManager';
import TextInput from '@components/TextInput';

import {useCurrencyListActions} from '@hooks/useCurrencyList';
Expand All @@ -16,7 +17,9 @@ import {setDraftSplitTransaction} from '@userActions/IOU/Split';

import CONST from '@src/CONST';

import React, {useState} from 'react';
import type {ComponentRef} from 'react';

import React, {useRef, useState} from 'react';
import {View} from 'react-native';

import AutomaticFieldHint from './AutomaticFieldHint';
Expand Down Expand Up @@ -49,6 +52,8 @@ function MerchantField({isMerchantRequired, shouldDisplayFieldError, formError}:
// Mirror the persisted merchant in local state so the controlled input updates synchronously as the user types;
// feeding the async Onyx value straight to `value` snaps the caret to the end on every keystroke (see #98647).
const [isMerchantInputFocused, setIsMerchantInputFocused] = useState(false);
const merchantInputRef = useRef<ComponentRef<typeof TextInput>>(null);
const shouldRestoreMerchantFocus = useRestoreConfirmationFieldFocus(transactionID, 'merchant', merchantInputRef);
const [merchantInput, setMerchantInput] = useState(displayMerchantValue);
const [prevDisplayValue, setPrevDisplayValue] = useState(displayMerchantValue);
const [prevTransactionID, setPrevTransactionID] = useState(transactionID);
Expand Down Expand Up @@ -130,10 +135,12 @@ function MerchantField({isMerchantRequired, shouldDisplayFieldError, formError}:
return (
<View style={[styles.mh4, styles.mv2]}>
<TextInput
ref={merchantInputRef}
value={merchantInput}
readOnly={didConfirm}
onChangeText={handleMerchantInputChange}
onFocus={() => {
recordFocusedConfirmationField(transactionID, 'merchant');
setIsMerchantInputFocused(true);
}}
onBlur={() => {
Expand All @@ -143,6 +150,7 @@ function MerchantField({isMerchantRequired, shouldDisplayFieldError, formError}:
accessibilityLabel={translate('common.merchant')}
errorText={merchantErrorText}
rightHandSideComponent={shouldShowAutomaticHint ? <AutomaticFieldHint /> : undefined}
shouldAllowFocusInLandscapeMode={shouldRestoreMerchantFocus}
/>
</View>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import MenuItem from '@components/MenuItem';
import MenuItemField from '@components/MenuItem/presets/MenuItemField';
import {useConfirmationFields} from '@components/MoneyRequestConfirmationFields/context';
import {recordFocusedConfirmationField, useRestoreConfirmationFieldFocus} from '@components/MoneyRequestConfirmationList/focusManager';
import NumberWithSymbolForm from '@components/NumberWithSymbolForm';
import type {NumberWithSymbolFormRef} from '@components/NumberWithSymbolForm';
import {SELECTION_LIST_POPOVER_HEADER_HEIGHT} from '@components/SelectionListPopoverHeader';
import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types';

import {useCurrencyListActions} from '@hooks/useCurrencyList';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -65,6 +67,8 @@ function TaxFields({policy, policyForMovingExpenses, iouCurrencyCode, canModifyT
const {isEditingSplitBill, onTaxAmountEmptyChange} = useConfirmationFields();
const {isBetaEnabled} = usePermissions();
const numberFormRef = useRef<NumberWithSymbolFormRef | null>(null);
const taxAmountInputRef = useRef<BaseTextInputRef | null>(null);
useRestoreConfirmationFieldFocus(transactionID, 'taxAmount', taxAmountInputRef);

const taxSlice = useTransactionSelector(transactionID, taxSliceSelector);
const {baseTransaction} = useSplitDraftBaseTransaction(transactionID);
Expand Down Expand Up @@ -241,6 +245,7 @@ function TaxFields({policy, policyForMovingExpenses, iouCurrencyCode, canModifyT
{canModifyTaxFields ? (
<View style={[styles.mh4, styles.mv2]}>
<NumberWithSymbolForm
ref={taxAmountInputRef}
numberFormRef={numberFormRef}
key={taxAmountInputKey}
displayAsTextInput
Expand All @@ -252,6 +257,7 @@ function TaxFields({policy, policyForMovingExpenses, iouCurrencyCode, canModifyT
label={translate('iou.taxAmount')}
errorText={shouldDisplayTaxAmountError ? translate('iou.error.invalidTaxAmount', formattedMaxTaxAmount) : ''}
onInputChange={handleTaxAmountChange}
onFocus={() => recordFocusedConfirmationField(transactionID, 'taxAmount')}
shouldShowBigNumberPad={false}
disabled={didConfirm}
/>
Expand Down
6 changes: 6 additions & 0 deletions src/components/MoneyRequestConfirmationList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ type MoneyRequestConfirmationListProps = {
/** Opens the participant picker owned by the page. */
onOpenParticipantPicker: () => void;

/** Whether the page participant picker is open. */
isParticipantPickerVisible?: boolean;

/** Whether the Share Submit flow can edit its participant without setting isFromGlobalCreate. */
shouldAllowParticipantEdit?: boolean;

/** The payment method the SettlementButton chose. */
onSendMoney?: (paymentMethod: PaymentMethodType | undefined) => void;

Expand Down
Loading
Loading