Skip to content

Commit 0ee2434

Browse files
Address tgolen review: inline trivial helper, trim comments, drop stray onboarding change
- Remove the single-line isLookingAroundOnboardingChoice helper and inline 'choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND' at every call site. - Remove the unhelpful what-restating comments in MoneyRequestHeaderSecondaryActions. - Revert navigateAfterOnboarding.ts fully to main so it's out of this PR's diff — it had picked up an unrelated navigateToSubmitWorkspaceAfterOnboarding reroute (Spend to Workspace > Categories) that isn't part of this PR. Co-authored-by: Shawn Borton <shawnborton@users.noreply.github.com>
1 parent 668fe15 commit 0ee2434

11 files changed

Lines changed: 19 additions & 48 deletions

File tree

src/components/MoneyRequestHeaderSecondaryActions.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,10 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
184184
const restrictedActionPolicyID = useRestrictedActionPolicyID(policy);
185185
const isTrackIntentUser = isTrackOnboardingChoice(introSelected?.choice);
186186

187-
// Data needed to launch the track-expense "Choose a recipient" flow from the "Send to someone" row (mirrors the
188-
// track-expense whisper in ChatActionableButtons).
189187
const activePolicy = useActivePolicy();
190188
const {isRestrictedToPreferredPolicy, preferredPolicyID} = usePreferredPolicy();
191-
// Memoize the selector factory so useOnyx keeps a stable selector identity across this header's frequent re-renders
192-
// (hold/violation/attribute churn) - an inline factory returns a fresh {filteredPoliciesCount, firstPolicyID} each render.
193189
const filteredPoliciesInfoSelector = useMemo(() => createFilteredPoliciesInfoSelector(currentUserLogin), [currentUserLogin]);
194190
const [filteredPoliciesInfo] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: filteredPoliciesInfoSelector});
195-
// Derive the draft IDs from the existing transactionDrafts subscription instead of subscribing to the same collection twice.
196-
// validTransactionDraftsSelector is keyed by transactionID, so its keys are exactly the valid draft transaction IDs.
197191
const draftTransactionIDs = useMemo(() => Object.keys(transactionDrafts ?? {}), [transactionDrafts]);
198192

199193
// Custom hooks
@@ -207,8 +201,6 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
207201
const isParentReportArchived = useReportIsArchived(report?.parentReportID);
208202
const {isBetaEnabled} = usePermissions();
209203
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
210-
// A self-DM split expense can only be submitted to a workspace, so the "Send to someone" row is gated on this - mirrors
211-
// the track-expense whisper (ChatActionableButtons) and the report-details menu (DynamicReportDetailsPage).
212204
const isSubmit2026BetaEnabled = isBetaEnabled(CONST.BETAS.SUBMIT_2026);
213205
const hasWorkspaceToSubmitToSelector = useMemo(() => createHasWorkspaceToSubmitToSelector(currentUserLogin, isSubmit2026BetaEnabled), [currentUserLogin, isSubmit2026BetaEnabled]);
214206
const [hasWorkspaceToSubmitTo = false] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: hasWorkspaceToSubmitToSelector});
@@ -638,11 +630,6 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
638630
return;
639631
}
640632

641-
// Reuse the exact track-expense whisper flow: create a draft from the tracked expense and open the
642-
// "Choose a recipient" RHP. Scoped against the self-DM (parentReport), matching the whisper.
643-
// Resolve the track-expense actionable whisper the same way the report-details menu does so the
644-
// convert flow can mark the original self-DM whisper resolved once the expense is sent - passing
645-
// undefined here would leave that whisper stranded and offering to submit an already-sent expense.
646633
createDraftTransactionAndNavigateToParticipantSelector({
647634
reportID: parentReport?.reportID,
648635
actionName: CONST.IOU.ACTION.SUBMIT,

src/libs/IOUAmountSubmission.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import cleanupAfterSkipConfirmSubmit from './Navigation/helpers/cleanupAfterSkip
4646
import {submitWithDismissFirst} from './Navigation/helpers/submitWithDismissFirst';
4747
import Navigation from './Navigation/Navigation';
4848
import {rand64} from './NumberUtils';
49-
import {isLookingAroundOnboardingChoice} from './OnboardingUtils';
5049
import {getParticipantsOption, getReportOption} from './OptionsListUtils';
5150
import Permissions from './Permissions';
5251
import {getLoginByAccountID} from './PersonalDetailsUtils';
@@ -430,7 +429,7 @@ function submitSkipConfirmationExpense(args: SubmitAmountArgs, ctx: SubmitAmount
430429
backToReport,
431430
optimisticChatReportID,
432431
linkedTrackedExpenseReportAction: transaction?.linkedTrackedExpenseReportAction,
433-
isLookingAroundUser: isLookingAroundOnboardingChoice(introSelected?.choice),
432+
isLookingAroundUser: introSelected?.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND,
434433
isSelfDMDestination,
435434
});
436435
};

src/libs/OnboardingUtils.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ function isTrackOnboardingChoice(choice: OnyxEntry<OnboardingPurpose>): choice i
2121
return choice === CONST.ONBOARDING_CHOICES.TRACK_BUSINESS || choice === CONST.ONBOARDING_CHOICES.TRACK_PERSONAL || choice === CONST.ONBOARDING_CHOICES.PERSONAL_SPEND;
2222
}
2323

24-
/**
25-
* Returns true when the onboarding choice is "Something else" (LOOKING_AROUND). Extracted so callers can read the
26-
* onboarding choice from Onyx in render context and pass the result into pure navigation helpers, rather than
27-
* having those helpers subscribe to Onyx themselves.
28-
*/
29-
function isLookingAroundOnboardingChoice(choice: OnyxEntry<OnboardingPurpose>): boolean {
30-
return choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND;
31-
}
32-
3324
/**
3425
* Counts the joinable policies that are actually surfaced during onboarding. SUBMIT-type policies are hidden
3526
* unless the SUBMIT_2026 beta is enabled, mirroring the filter the Workspaces and PrivateDomain screens use to
@@ -57,4 +48,4 @@ function isSupportedPendingInviteOnboarding(introSelected: OnyxEntry<IntroSelect
5748

5849
return isSupportedInviteOnboardingChoice(introSelected.choice) && !isInviteIOUorInvoice;
5950
}
60-
export {getVisibleJoinablePoliciesCount, isLookingAroundOnboardingChoice, isSupportedInviteOnboardingChoice, isSupportedPendingInviteOnboarding, isTrackOnboardingChoice};
51+
export {getVisibleJoinablePoliciesCount, isSupportedInviteOnboardingChoice, isSupportedPendingInviteOnboarding, isTrackOnboardingChoice};

src/libs/navigateAfterOnboarding.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {handleRHPVariantNavigation, shouldOpenRHPVariant} from '@components/Side
33
import CONST from '@src/CONST';
44
import ONYXKEYS from '@src/ONYXKEYS';
55
import ROUTES from '@src/ROUTES';
6-
import type {Route} from '@src/ROUTES';
76
import type {OnboardingRHPVariant, ReportNameValuePairs} from '@src/types/onyx';
87

98
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
@@ -18,6 +17,7 @@ import {dismissOnboardingModalBeforeExit} from './Navigation/helpers/OnboardingN
1817
import shouldOpenOnAdminRoom from './Navigation/helpers/shouldOpenOnAdminRoom';
1918
import Navigation from './Navigation/Navigation';
2019
import {findLastAccessedReport, isConciergeChatReport, isSelfDM} from './ReportUtils';
20+
import {buildCannedSearchQuery} from './SearchQueryUtils';
2121

2222
let onboardingRHPVariant: OnyxEntry<OnboardingRHPVariant>;
2323
Onyx.connectWithoutView({
@@ -140,9 +140,8 @@ function navigateAfterOnboardingWithMicrotaskQueue(
140140
}
141141

142142
/**
143-
* After creating or joining a Submit workspace during onboarding,
144-
* navigate to Workspace > Categories with the side panel open so
145-
* the #admins room is visible in Concierge Anywhere.
143+
* After creating or joining a Submit workspace during onboarding, navigate to Spend > Expenses
144+
* with the side panel open so the #admins room is visible in Concierge Anywhere.
146145
*/
147146
function navigateToSubmitWorkspaceAfterOnboarding(policyID?: string, shouldUseNarrowLayout = false) {
148147
setDisableDismissOnEscape(false);
@@ -153,11 +152,7 @@ function navigateToSubmitWorkspaceAfterOnboarding(policyID?: string, shouldUseNa
153152
}
154153

155154
setOnboardingRHPVariant(CONST.ONBOARDING_RHP_VARIANT.RHP_ADMINS_ROOM);
156-
157-
const categoriesRoute = ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID);
158-
const backToRoute = shouldUseNarrowLayout ? ROUTES.WORKSPACE_INITIAL.getRoute(policyID) : ROUTES.WORKSPACES_LIST.route;
159-
Navigation.navigate(`${categoriesRoute}?backTo=${encodeURIComponent(backToRoute)}` as Route);
160-
155+
Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: buildCannedSearchQuery({type: CONST.SEARCH.DATA_TYPES.EXPENSE})}));
161156
SidePanelActions.openSidePanel(!shouldUseNarrowLayout);
162157
}
163158

src/pages/Share/SubmitDetailsPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import cleanupAndNavigateAfterExpenseCreate from '@libs/Navigation/helpers/clean
4444
import Navigation from '@libs/Navigation/Navigation';
4545
import type {ShareNavigatorParamList} from '@libs/Navigation/types';
4646
import {rand64} from '@libs/NumberUtils';
47-
import {isLookingAroundOnboardingChoice, isTrackOnboardingChoice} from '@libs/OnboardingUtils';
47+
import {isTrackOnboardingChoice} from '@libs/OnboardingUtils';
4848
import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils';
4949
import {hasOnlyPersonalPolicies as hasOnlyPersonalPoliciesUtil, isGroupPolicy} from '@libs/PolicyUtils';
5050
import {shouldValidateFile} from '@libs/ReceiptUtils';
@@ -151,7 +151,7 @@ function SubmitDetailsPage({
151151
const fileType = shouldUsePreValidatedFile ? (validFilesToUpload?.type ?? CONST.RECEIPT_ALLOWED_FILE_TYPES.JPEG) : (currentAttachment?.mimeType ?? '');
152152
const [hasOnlyPersonalPolicies = false] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: hasOnlyPersonalPoliciesUtil});
153153
const isTrackIntentUser = isTrackOnboardingChoice(introSelected?.choice);
154-
const isLookingAroundUser = isLookingAroundOnboardingChoice(introSelected?.choice);
154+
const isLookingAroundUser = introSelected?.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND;
155155

156156
const hasEndedOpenSubmitFlowSpan = useRef(false);
157157
const endOpenSubmitFlowSpan = () => {

src/pages/iou/request/step/IOURequestStepConfirmation.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ import {
5757
import {submitWithDismissFirst} from '@libs/Navigation/helpers/submitWithDismissFirst';
5858
import Navigation from '@libs/Navigation/Navigation';
5959
import type {MoneyRequestNavigatorParamList} from '@libs/Navigation/types';
60-
import {isLookingAroundOnboardingChoice} from '@libs/OnboardingUtils';
6160
import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils';
6261
import {getDistanceRateCustomUnit} from '@libs/PolicyUtils';
6362
import {findSelfDMReportID, generateReportID, getReportOrDraftReport, isMoneyRequestReport, isPolicyExpenseChat as isPolicyExpenseChatUtils} from '@libs/ReportUtils';
@@ -277,7 +276,7 @@ function IOURequestStepConfirmation({
277276
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
278277
// "Something else" (LOOKING_AROUND) users have no workspace, so their global-create expense lands in their self-DM.
279278
// We route them to Spend > Expenses (Search) after creating instead of dropping them into that self-DM report.
280-
const isLookingAroundUser = isLookingAroundOnboardingChoice(introSelected?.choice);
279+
const isLookingAroundUser = introSelected?.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND;
281280
const privateIsArchivedMap = usePrivateIsArchivedMap();
282281

283282
const receiptFilename = transaction?.receipt?.filename;

src/pages/iou/request/step/IOURequestStepDistance.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {getWaypointsHasUnsavedChanges} from '@libs/MoneyRequestUtils';
4040
import Navigation from '@libs/Navigation/Navigation';
4141
import OnyxTabNavigator, {TabScreenWithFocusTrapWrapper, TopTab} from '@libs/Navigation/OnyxTabNavigator';
4242
import {roundToTwoDecimalPlaces} from '@libs/NumberUtils';
43-
import {isLookingAroundOnboardingChoice, isTrackOnboardingChoice} from '@libs/OnboardingUtils';
43+
import {isTrackOnboardingChoice} from '@libs/OnboardingUtils';
4444
import {isPolicyExpenseChat as isPolicyExpenseChatUtil, isSelfDM} from '@libs/ReportUtils';
4545
import {getDistanceInMeters, getRateID, getRequestType, getSelectedRouteKey, hasManualDistanceOverride, haveWaypointAddressesChanged} from '@libs/TransactionUtils';
4646

@@ -318,7 +318,7 @@ function IOURequestStepDistance({
318318
const skipConfirmationPreMountRoute = getSkipConfirmationPreMountDestinationRoute(
319319
shouldSkipConfirmation,
320320
report?.reportID,
321-
isLookingAroundOnboardingChoice(introSelected?.choice),
321+
introSelected?.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND,
322322
isSelfDM(report),
323323
);
324324
usePreMountDestination(skipConfirmationPreMountRoute);

src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import cleanupAfterSkipConfirmSubmit from '@libs/Navigation/helpers/cleanupAfter
1212
import {submitWithDismissFirst} from '@libs/Navigation/helpers/submitWithDismissFirst';
1313
import Navigation from '@libs/Navigation/Navigation';
1414
import {roundToTwoDecimalPlaces} from '@libs/NumberUtils';
15-
import {isLookingAroundOnboardingChoice} from '@libs/OnboardingUtils';
1615
import {getPolicyExpenseChat, isSelfDM} from '@libs/ReportUtils';
1716
import type {OptionData} from '@libs/ReportUtils';
1817
import shouldUseDefaultExpensePolicy from '@libs/shouldUseDefaultExpensePolicy';
@@ -215,7 +214,7 @@ function handleMoneyRequestStepDistanceNavigation({
215214
const isGPSDistance = gpsDistance !== undefined && gpsCoordinates !== undefined;
216215
const distanceRequestType = getDistanceRequestType(transaction);
217216
// Derived here (rather than read from Onyx) from the onboarding choice the calling component/hook already passes in.
218-
const isLookingAroundUser = isLookingAroundOnboardingChoice(introSelected?.choice);
217+
const isLookingAroundUser = introSelected?.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND;
219218
// Whether this expense's sole destination is the current user's self-DM. Scopes the LOOKING_AROUND
220219
// "route to Spend > Expenses" behaviour to the self-DM case (matches the confirmation step).
221220
const isSelfDMDestination = isSelfDMSoleDestination(participants, iouType, currentUserAccountID);

src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Log from '@libs/Log';
2727
import cleanupAfterSkipConfirmSubmit from '@libs/Navigation/helpers/cleanupAfterSkipConfirmSubmit';
2828
import {submitWithDismissFirst} from '@libs/Navigation/helpers/submitWithDismissFirst';
2929
import {rand64} from '@libs/NumberUtils';
30-
import {isLookingAroundOnboardingChoice, isTrackOnboardingChoice} from '@libs/OnboardingUtils';
30+
import {isTrackOnboardingChoice} from '@libs/OnboardingUtils';
3131
import {isMoneyRequestReport as isMoneyRequestReportReportUtils} from '@libs/ReportUtils';
3232
import {cancelSpan} from '@libs/telemetry/activeSpans';
3333
import type {ReceiptCaptureSource} from '@libs/telemetry/ReceiptObservability';
@@ -108,7 +108,7 @@ function ScanSkipConfirmation({report, action, iouType, reportID, transactionID,
108108
selector: shouldStartLocationPermissionFlowSelector,
109109
});
110110
const isTrackIntentUser = isTrackOnboardingChoice(introSelected?.choice);
111-
const isLookingAroundUser = isLookingAroundOnboardingChoice(introSelected?.choice);
111+
const isLookingAroundUser = introSelected?.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND;
112112

113113
const [transactions] = useOptimisticDraftTransactions(transaction);
114114
const {isMultiScanEnabled} = useMultiScanState();

src/pages/iou/request/step/confirmation/useExpenseSubmission.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import dismissModalAndOpenReportInInboxTabHelper from '@libs/Navigation/helpers/
2727
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
2828
import navigateAfterExpenseCreate from '@libs/Navigation/helpers/navigateAfterExpenseCreate';
2929
import {rand64, roundToTwoDecimalPlaces} from '@libs/NumberUtils';
30-
import {isLookingAroundOnboardingChoice, isTrackOnboardingChoice} from '@libs/OnboardingUtils';
30+
import {isTrackOnboardingChoice} from '@libs/OnboardingUtils';
3131
import {getNewAccountIDsAndLogins} from '@libs/PersonalDetailsUtils';
3232
import {isTaxTrackingEnabled} from '@libs/PolicyUtils';
3333
import {
@@ -293,7 +293,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) {
293293
const [odometerDraft] = useOnyx(ONYXKEYS.ODOMETER_DRAFT);
294294
const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector});
295295
const isTrackIntentUser = isTrackOnboardingChoice(introSelected?.choice);
296-
const isLookingAroundUser = isLookingAroundOnboardingChoice(introSelected?.choice);
296+
const isLookingAroundUser = introSelected?.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND;
297297
// Onboarding task data
298298
const {
299299
taskReport: viewTourTaskReport,

0 commit comments

Comments
 (0)