Skip to content
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
1 change: 0 additions & 1 deletion src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ const CONST = {
TRACK_FLOWS: 'trackFlows',
EXPENSIFY_CARD_EU_UK: 'expensifyCardEuUk',
EUR_BILLING: 'eurBilling',
MANUAL_DISTANCE: 'manualDistance',
NO_OPTIMISTIC_TRANSACTION_THREADS: 'noOptimisticTransactionThreads',
UBER_FOR_BUSINESS: 'uberForBusiness',
CUSTOM_REPORT_NAMES: 'newExpensifyCustomReportNames',
Expand Down
9 changes: 3 additions & 6 deletions src/components/MoneyRequestConfirmationListFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {ValueOf} from 'type-fest';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import usePrevious from '@hooks/usePrevious';
import useThemeStyles from '@hooks/useThemeStyles';
import {convertToDisplayString} from '@libs/CurrencyUtils';
Expand Down Expand Up @@ -274,8 +273,6 @@ function MoneyRequestConfirmationListFooter({
const styles = useThemeStyles();
const {translate, toLocaleDigit, localeCompare} = useLocalize();
const {isOffline} = useNetwork();
const {isBetaEnabled} = usePermissions();
const isManualDistanceEnabled = isBetaEnabled(CONST.BETAS.MANUAL_DISTANCE);

const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true});
const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true});
Expand Down Expand Up @@ -505,7 +502,7 @@ function MoneyRequestConfirmationListFooter({
item: (
<MenuItemWithTopDescription
key={translate('common.rate')}
shouldShowRightIcon={!!rate && !isReadOnly && (isPolicyExpenseChat || isManualDistanceEnabled)}
shouldShowRightIcon={!!rate && !isReadOnly}

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.

PERF-6

This line changes from a more specific conditional check to a broader one that may cause unnecessary re-renders. The original code included isPolicyExpenseChat as part of the condition, providing more granular control.

The removed condition (isPolicyExpenseChat || isManualDistanceEnabled) has been simplified to just checking the rate and read-only state, but this could lead to the right icon being shown in cases where it previously wouldn't have been, potentially affecting user experience and performance.

title={DistanceRequestUtils.getRateForDisplay(unit, rate, currency, translate, toLocaleDigit, isOffline)}
description={translate('common.rate')}
style={[styles.moneyRequestMenuItem]}
Expand All @@ -515,7 +512,7 @@ function MoneyRequestConfirmationListFooter({
return;
}

if (isManualDistanceEnabled && !isPolicyExpenseChat) {
if (!isPolicyExpenseChat) {

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.

PERF-6

The conditional logic here has been simplified by removing the isManualDistanceEnabled check. While this removes beta-gated functionality, ensure that the remaining condition !isPolicyExpenseChat properly handles all the use cases that were previously covered by the more complex conditional.

Consider adding a comment explaining why this specific navigation path is taken when not in a policy expense chat context.

Navigation.navigate(
ROUTES.MONEY_REQUEST_UPGRADE.getRoute({
action,
Expand All @@ -533,7 +530,7 @@ function MoneyRequestConfirmationListFooter({
}}
brickRoadIndicator={shouldDisplayDistanceRateError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
disabled={didConfirm}
interactive={!!rate && !isReadOnly && (isPolicyExpenseChat || isManualDistanceEnabled)}
interactive={!!rate && !isReadOnly}
/>
),
shouldShow: isDistanceRequest,
Expand Down
16 changes: 5 additions & 11 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

let allTransactions: OnyxCollection<Transaction> = {};

Onyx.connect({

Check warning on line 117 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -126,7 +126,7 @@
});

let allReports: OnyxCollection<Report> = {};
Onyx.connect({

Check warning on line 129 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -135,7 +135,7 @@
});

let allTransactionViolations: OnyxCollection<TransactionViolations> = {};
Onyx.connect({

Check warning on line 138 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => (allTransactionViolations = value),
Expand All @@ -143,7 +143,7 @@

let currentUserEmail = '';
let currentUserAccountID = -1;
Onyx.connect({

Check warning on line 146 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (val) => {
currentUserEmail = val?.email ?? '';
Expand Down Expand Up @@ -216,22 +216,16 @@
return isCardTransaction(transaction) && transaction?.comment?.liabilityType === CONST.TRANSACTION.LIABILITY_TYPE.RESTRICT;
}

function getRequestType(transaction: OnyxEntry<Transaction>, isManualDistanceEnabled?: boolean): IOURequestType {
if (isManualDistanceEnabled) {
if (isManualDistanceRequest(transaction)) {
return CONST.IOU.REQUEST_TYPE.DISTANCE_MANUAL;
}
if (isMapDistanceRequest(transaction)) {
return CONST.IOU.REQUEST_TYPE.DISTANCE_MAP;
}
function getRequestType(transaction: OnyxEntry<Transaction>): IOURequestType {

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.

PERF-2

The function signature has been simplified by removing the isManualDistanceEnabled parameter, which is good for performance. However, consider adding early returns for the most common cases first to optimize performance.

Current implementation already follows good practices by checking isManualDistanceRequest first, then isMapDistanceRequest, which are likely the less common cases before falling back to more common ones.

if (isManualDistanceRequest(transaction)) {
return CONST.IOU.REQUEST_TYPE.DISTANCE_MANUAL;
}
if (isDistanceRequest(transaction)) {
return CONST.IOU.REQUEST_TYPE.DISTANCE;
if (isMapDistanceRequest(transaction)) {
return CONST.IOU.REQUEST_TYPE.DISTANCE_MAP;
}
if (isScanRequest(transaction)) {
return CONST.IOU.REQUEST_TYPE.SCAN;
}

if (isPerDiemRequest(transaction)) {
return CONST.IOU.REQUEST_TYPE.PER_DIEM;
}
Expand Down
29 changes: 6 additions & 23 deletions src/libs/actions/QuickActionNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@ type NavigateToQuickActionParams = {
isValidReport: boolean;
quickAction: QuickAction;
selectOption: (onSelected: () => void, shouldRestrictAction: boolean) => void;
isManualDistanceTrackingEnabled?: boolean;
lastDistanceExpenseType?: DistanceExpenseType;
};

function getQuickActionRequestType(
action: QuickActionName | undefined,
lastDistanceExpenseType?: DistanceExpenseType,
isManualDistanceTrackingEnabled?: boolean,
): IOURequestType | undefined {
function getQuickActionRequestType(action: QuickActionName | undefined, lastDistanceExpenseType?: DistanceExpenseType): IOURequestType | undefined {
if (!action) {
return;
}
Expand All @@ -30,11 +25,7 @@ function getQuickActionRequestType(
} else if ([CONST.QUICK_ACTIONS.REQUEST_SCAN, CONST.QUICK_ACTIONS.SPLIT_SCAN, CONST.QUICK_ACTIONS.TRACK_SCAN].some((a) => a === action)) {
requestType = CONST.IOU.REQUEST_TYPE.SCAN;
} else if ([CONST.QUICK_ACTIONS.REQUEST_DISTANCE, CONST.QUICK_ACTIONS.SPLIT_DISTANCE, CONST.QUICK_ACTIONS.TRACK_DISTANCE].some((a) => a === action)) {
if (isManualDistanceTrackingEnabled) {
requestType = lastDistanceExpenseType ?? CONST.IOU.REQUEST_TYPE.DISTANCE_MAP;
} else {
requestType = CONST.IOU.REQUEST_TYPE.DISTANCE;
}
requestType = lastDistanceExpenseType ?? CONST.IOU.REQUEST_TYPE.DISTANCE_MAP;
} else if (action === CONST.QUICK_ACTIONS.PER_DIEM) {
requestType = CONST.IOU.REQUEST_TYPE.PER_DIEM;
}
Expand All @@ -43,9 +34,9 @@ function getQuickActionRequestType(
}

function navigateToQuickAction(params: NavigateToQuickActionParams) {
const {isValidReport, quickAction, selectOption, isManualDistanceTrackingEnabled, lastDistanceExpenseType} = params;
const {isValidReport, quickAction, selectOption, lastDistanceExpenseType} = params;
const reportID = isValidReport && quickAction?.chatReportID ? quickAction?.chatReportID : generateReportID();
const requestType = getQuickActionRequestType(quickAction?.action, lastDistanceExpenseType, isManualDistanceTrackingEnabled);
const requestType = getQuickActionRequestType(quickAction?.action, lastDistanceExpenseType);

switch (quickAction?.action) {
case CONST.QUICK_ACTIONS.REQUEST_MANUAL:
Expand All @@ -69,18 +60,10 @@ function navigateToQuickAction(params: NavigateToQuickActionParams) {
selectOption(() => startMoneyRequest(CONST.IOU.TYPE.TRACK, reportID, requestType, true), false);
break;
case CONST.QUICK_ACTIONS.REQUEST_DISTANCE:

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.

Code Simplification

Good simplification! The removal of the isManualDistanceTrackingEnabled conditional check and consistently using startDistanceRequest for distance-related actions makes the code more predictable and easier to maintain.

This change eliminates the complexity of having two different code paths based on the beta flag and ensures consistent behavior for distance request handling.

if (isManualDistanceTrackingEnabled) {
selectOption(() => startDistanceRequest(CONST.IOU.TYPE.SUBMIT, reportID, requestType, true), false);
return;
}
selectOption(() => startMoneyRequest(CONST.IOU.TYPE.SUBMIT, reportID, requestType, true), true);
selectOption(() => startDistanceRequest(CONST.IOU.TYPE.SUBMIT, reportID, requestType, true), false);
break;
case CONST.QUICK_ACTIONS.TRACK_DISTANCE:
if (isManualDistanceTrackingEnabled) {
selectOption(() => startDistanceRequest(CONST.IOU.TYPE.TRACK, reportID, requestType, true), false);
return;
}
selectOption(() => startMoneyRequest(CONST.IOU.TYPE.TRACK, reportID, requestType, true), false);
selectOption(() => startDistanceRequest(CONST.IOU.TYPE.TRACK, reportID, requestType, true), false);
break;
default:
}
Expand Down
4 changes: 1 addition & 3 deletions src/pages/TransactionReceiptPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {useEffect} from 'react';
import AttachmentModal from '@components/AttachmentModal';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import {navigateToStartStepIfScanFileCannotBeRead} from '@libs/actions/IOU';
import {openReport} from '@libs/actions/Report';
import getReceiptFilenameFromTransaction from '@libs/getReceiptFilenameFromTransaction';
Expand Down Expand Up @@ -30,7 +29,6 @@ function TransactionReceipt({route}: TransactionReceiptProps) {
const [transactionMain] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {canBeMissing: true});
const [transactionDraft] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {canBeMissing: true});
const [reportMetadata = CONST.DEFAULT_REPORT_METADATA] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, {canBeMissing: true});
const {isBetaEnabled} = usePermissions();

const mergeTransactionID = 'mergeTransactionID' in route.params ? route.params.mergeTransactionID : undefined;
const isFromReviewDuplicates = 'isFromReviewDuplicates' in route.params ? route.params.isFromReviewDuplicates === 'true' : undefined;
Expand Down Expand Up @@ -79,7 +77,7 @@ function TransactionReceipt({route}: TransactionReceiptProps) {
return;
}

const requestType = getRequestType(transaction, isBetaEnabled(CONST.BETAS.MANUAL_DISTANCE));
const requestType = getRequestType(transaction);
const receiptFilename = getReceiptFilenameFromTransaction(transaction);
const receiptType = transaction?.receipt?.type;
navigateToStartStepIfScanFileCannotBeRead(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Tooltip from '@components/Tooltip/PopoverAnchorTooltip';
import useEnvironment from '@hooks/useEnvironment';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import usePrevious from '@hooks/usePrevious';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
Expand Down Expand Up @@ -131,12 +130,9 @@ function AttachmentPickerWithMenuItems({
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`, {canBeMissing: true});
const [lastDistanceExpenseType] = useOnyx(ONYXKEYS.NVP_LAST_DISTANCE_EXPENSE_TYPE, {canBeMissing: true});
const {isProduction} = useEnvironment();
const {isBetaEnabled} = usePermissions();
const {setIsLoaderVisible} = useFullScreenLoader();
const isReportArchived = useReportIsArchived(report?.reportID);

const isManualDistanceTrackingEnabled = isBetaEnabled(CONST.BETAS.MANUAL_DISTANCE);

const selectOption = useCallback(
(onSelected: () => void, shouldRestrictAction: boolean) => {
if (shouldRestrictAction && policy && shouldRestrictUserBillableActions(policy.id)) {
Expand Down Expand Up @@ -172,17 +168,12 @@ function AttachmentPickerWithMenuItems({
shouldCallAfterModalHide: shouldUseNarrowLayout,
onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.SUBMIT, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), true),
},
...(isManualDistanceTrackingEnabled
? [
{
icon: Expensicons.Location,
text: translate('quickAction.recordDistance'),
shouldCallAfterModalHide: shouldUseNarrowLayout,
onSelected: () =>
selectOption(() => startDistanceRequest(CONST.IOU.TYPE.SUBMIT, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID), lastDistanceExpenseType), true),
},
]
: []),
{

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.

Code Simplification

Excellent refactoring! The removal of the conditional array spread based on isManualDistanceTrackingEnabled simplifies the menu items array construction and eliminates unnecessary complexity.

The distance tracking menu item is now always available, which provides a more consistent user experience and eliminates the need for runtime beta flag checks.

icon: Expensicons.Location,
text: translate('quickAction.recordDistance'),
shouldCallAfterModalHide: shouldUseNarrowLayout,
onSelected: () => selectOption(() => startDistanceRequest(CONST.IOU.TYPE.SUBMIT, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID), lastDistanceExpenseType), true),
},
],
[CONST.IOU.TYPE.PAY]: [
{
Expand All @@ -207,17 +198,12 @@ function AttachmentPickerWithMenuItems({
shouldCallAfterModalHide: shouldUseNarrowLayout,
onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.TRACK, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), true),
},
...(isManualDistanceTrackingEnabled
? [
{
icon: Expensicons.Location,
text: translate('iou.trackDistance'),
shouldCallAfterModalHide: shouldUseNarrowLayout,
onSelected: () =>
selectOption(() => startDistanceRequest(CONST.IOU.TYPE.TRACK, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID), lastDistanceExpenseType), true),
},
]
: []),
{
icon: Expensicons.Location,
text: translate('iou.trackDistance'),
shouldCallAfterModalHide: shouldUseNarrowLayout,
onSelected: () => selectOption(() => startDistanceRequest(CONST.IOU.TYPE.TRACK, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID), lastDistanceExpenseType), true),
},
],
[CONST.IOU.TYPE.INVOICE]: [
{
Expand All @@ -241,7 +227,6 @@ function AttachmentPickerWithMenuItems({
selectOption,
isDelegateAccessRestricted,
showDelegateNoAccessModal,
isManualDistanceTrackingEnabled,
isReportArchived,
lastDistanceExpenseType,
]);
Expand Down
50 changes: 22 additions & 28 deletions src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref
const {isOffline} = useNetwork();
const {isBetaEnabled} = usePermissions();
const isBlockedFromSpotnanaTravel = isBetaEnabled(CONST.BETAS.PREVENT_SPOTNANA_TRAVEL);
const isManualDistanceTrackingEnabled = isBetaEnabled(CONST.BETAS.MANUAL_DISTANCE);
const [primaryLogin] = useOnyx(ONYXKEYS.ACCOUNT, {selector: accountPrimaryLoginSelector, canBeMissing: true});
const primaryContactMethod = primaryLogin ?? session?.email ?? '';
const [travelSettings] = useOnyx(ONYXKEYS.NVP_TRAVEL_SETTINGS, {canBeMissing: true});
Expand Down Expand Up @@ -353,7 +352,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref
showDelegateNoAccessModal();
return;
}
navigateToQuickAction({isValidReport, quickAction, selectOption, isManualDistanceTrackingEnabled, lastDistanceExpenseType});
navigateToQuickAction({isValidReport, quickAction, selectOption, lastDistanceExpenseType});
});
};
return [
Expand Down Expand Up @@ -413,7 +412,6 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref
isDelegateAccessRestricted,
showDelegateNoAccessModal,
isReportArchived,
isManualDistanceTrackingEnabled,
lastDistanceExpenseType,
allTransactionDrafts,
]);
Expand All @@ -438,31 +436,27 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref

const menuItems = [
...expenseMenuItems,
...(isManualDistanceTrackingEnabled
? [
{
icon: Expensicons.Location,
text: translate('iou.trackDistance'),
shouldCallAfterModalHide: shouldUseNarrowLayout,
onSelected: () => {
interceptAnonymousUser(() => {
if (shouldRedirectToExpensifyClassic) {
setModalVisible(true);
return;
}
// Start the flow to start tracking a distance request
startDistanceRequest(
CONST.IOU.TYPE.CREATE,
// When starting to create an expense from the global FAB, there is not an existing report yet. A random optimistic reportID is generated and used
// for all of the routes in the creation flow.
generateReportID(),
lastDistanceExpenseType,
);
});
},
},
]
: []),
{

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.

Performance and Code Quality Improvement

Great change! The removal of the conditional array spread based on isManualDistanceTrackingEnabled eliminates:

  1. Runtime conditional logic - No more beta flag checks during menu rendering
  2. Array spread complexity - Cleaner, more readable menu items array
  3. Dependency tracking - Fewer variables in the useMemo dependency array

The distance tracking option is now always available, providing consistent UX and reducing code complexity.

icon: Expensicons.Location,
text: translate('iou.trackDistance'),
shouldCallAfterModalHide: shouldUseNarrowLayout,
onSelected: () => {
interceptAnonymousUser(() => {
if (shouldRedirectToExpensifyClassic) {
setModalVisible(true);
return;
}
// Start the flow to start tracking a distance request
startDistanceRequest(
CONST.IOU.TYPE.CREATE,
// When starting to create an expense from the global FAB, there is not an existing report yet. A random optimistic reportID is generated and used
// for all of the routes in the creation flow.
generateReportID(),
lastDistanceExpenseType,
);
});
},
},
...(shouldShowCreateReportOption
? [
{
Expand Down
3 changes: 1 addition & 2 deletions src/pages/iou/request/IOURequestStartPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ function IOURequestStartPage({
}, [headerWithBackBtnContainerElement, tabBarContainerElement, activeTabContainerElement]);

const {isBetaEnabled} = usePermissions();
const manualDistanceTrackingEnabled = isBetaEnabled(CONST.BETAS.MANUAL_DISTANCE);
const setTestReceiptAndNavigateRef = useRef<() => void>(() => {});
const {shouldShowProductTrainingTooltip, renderProductTrainingTooltip} = useProductTrainingContext(
CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP,
Expand Down Expand Up @@ -266,7 +265,7 @@ function IOURequestStartPage({
</TabScreenWithFocusTrapWrapper>
)}
</TopTab.Screen>
{(!manualDistanceTrackingEnabled || iouType === CONST.IOU.TYPE.SPLIT) && (
{iouType === CONST.IOU.TYPE.SPLIT && (

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.

⚠️ Logic Change Review

The condition has changed from (!manualDistanceTrackingEnabled || iouType === CONST.IOU.TYPE.SPLIT) to just iouType === CONST.IOU.TYPE.SPLIT.

This means the distance tab will now only be shown for split requests, whereas previously it was shown for:

  1. All requests when manual distance tracking was disabled, OR
  2. Split requests when manual distance tracking was enabled

Please verify this behavioral change aligns with the intended UX - non-split distance requests may no longer have this tab available.

@dominictb dominictb Oct 19, 2025

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.

I don't know if I should leave this comment for the add new distance routes PR or this one but we need to update the old route for the Hybrid app's shortcut here too (internal repo).

See #71672

This is admittedly an edge case that was hard to anticipate.

<TopTab.Screen name={CONST.TAB_REQUEST.DISTANCE}>
{() => (
<TabScreenWithFocusTrapWrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function IOURequestStepAmount({
const textInput = useRef<BaseTextInputRef | null>(null);
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const isSaveButtonPressed = useRef(false);
const iouRequestType = getRequestType(transaction, isBetaEnabled(CONST.BETAS.MANUAL_DISTANCE));
const iouRequestType = getRequestType(transaction);

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.

Performance Improvement

Good refactoring! The getRequestType function call has been simplified by removing the isBetaEnabled(CONST.BETAS.MANUAL_DISTANCE) parameter. This eliminates:

  1. Unnecessary hook call - No more usePermissions hook usage
  2. Runtime beta flag evaluation - Removes conditional logic overhead
  3. Function parameter complexity - Cleaner function signature

The function now has more predictable behavior without the beta flag dependency.

const policyID = report?.policyID;

const isReportArchived = useReportIsArchived(report?.reportID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function IOURequestStepConfirmation({
const [isDraggingOver, setIsDraggingOver] = useState(false);

const [receiptFiles, setReceiptFiles] = useState<Record<string, Receipt>>({});
const requestType = getRequestType(transaction, isBetaEnabled(CONST.BETAS.MANUAL_DISTANCE));
const requestType = getRequestType(transaction);
const isDistanceRequest = isDistanceRequestTransactionUtils(transaction);
const isManualDistanceRequest = isManualDistanceRequestTransactionUtils(transaction);
const isPerDiemRequest = requestType === CONST.IOU.REQUEST_TYPE.PER_DIEM;
Expand Down
Loading
Loading