Skip to content

Commit aede2dd

Browse files
committed
fixed comments and namings
1 parent 869fce5 commit aede2dd

4 files changed

Lines changed: 53 additions & 53 deletions

File tree

src/hooks/useCreateReport.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import useCreateEmptyReportConfirmation from './useCreateEmptyReportConfirmation
1414
import useHasEmptyReportsForPolicy from './useHasEmptyReportsForPolicy';
1515
import useOnyx from './useOnyx';
1616

17-
type UseCreateReportActionParams = {
17+
type UseCreateReportParams = {
1818
/** Callback that creates the report and navigates after creation */
1919
onCreateReport: (shouldDismissEmptyReportsConfirmation?: boolean) => void;
2020
/** Group paid policies with expense chat enabled */
@@ -23,9 +23,9 @@ type UseCreateReportActionParams = {
2323
shouldHandleNavigationBack?: boolean;
2424
};
2525

26-
type UseCreateReportActionResult = {
27-
/** The action to trigger when the user clicks "Create report" */
28-
createReportAction: () => void;
26+
type UseCreateReportResult = {
27+
/** The callback to trigger when the user clicks "Create report" */
28+
createReport: () => void;
2929
/** Whether the menu item/button should be visible */
3030
isVisible: boolean;
3131
};
@@ -36,14 +36,14 @@ type UseCreateReportActionResult = {
3636
*
3737
* Decision flow:
3838
* 1. Navigate to upgrade path if user has no valid group policies at all
39-
* 2. Navigate to workspace selector if default is personal AND there are 2+ non-personal workspaces, or if the chosen default is billing-restricted and alternatives exist
39+
* 2. Navigate to workspace selector if default is personal AND there are at least 2 non-personal workspaces, or if the chosen default is billing-restricted and alternatives exist
4040
* 3. Show empty report confirmation or create directly if workspace is valid
4141
* 4. Navigate to restricted action if billing restricts the workspace
4242
*/
43-
export default function useCreateReportAction({onCreateReport, groupPoliciesWithChatEnabled, shouldHandleNavigationBack = true}: UseCreateReportActionParams): UseCreateReportActionResult {
43+
export default function useCreateReport({onCreateReport, groupPoliciesWithChatEnabled, shouldHandleNavigationBack = true}: UseCreateReportParams): UseCreateReportResult {
4444
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
4545
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`);
46-
const [, policiesMeta] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
46+
const [, policiesLoadStatus] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
4747
const [ownerBillingGracePeriodEnd] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
4848
const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
4949
const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED);
@@ -53,7 +53,7 @@ export default function useCreateReportAction({onCreateReport, groupPoliciesWith
5353
// Gate visibility and routing on policy hydration. Without this, during Onyx cold-start
5454
// groupPoliciesWithChatEnabled.length === 0 would be true even for users who actually have
5555
// workspaces, sending them to MONEY_REQUEST_UPGRADE as if they had none.
56-
const arePoliciesLoaded = !isLoadingOnyxValue(policiesMeta);
56+
const arePoliciesLoaded = !isLoadingOnyxValue(policiesLoadStatus);
5757
const isVisible = arePoliciesLoaded;
5858
const shouldNavigateToUpgradePath = groupPoliciesWithChatEnabled.length === 0;
5959

@@ -70,7 +70,7 @@ export default function useCreateReportAction({onCreateReport, groupPoliciesWith
7070
shouldHandleNavigationBack,
7171
});
7272

73-
const createReportAction = useCallback(() => {
73+
const createReport = useCallback(() => {
7474
interceptAnonymousUser(() => {
7575
if (!arePoliciesLoaded) {
7676
return;
@@ -94,10 +94,10 @@ export default function useCreateReportAction({onCreateReport, groupPoliciesWith
9494

9595
const workspaceIDForReportCreation = defaultChatEnabledPolicyID;
9696

97-
// Per spec: show the workspace selector only when the default (active) workspace is personal
98-
// AND the user has 2+ non-personal workspaces to choose between. We also fall back to the
99-
// selector if the chosen default is billing-restricted and alternatives exist, so the user
100-
// isn't dead-ended on the restricted-action page.
97+
// Show the workspace selector only when the default workspace is personal and there are
98+
// at least 2 non-personal workspaces to choose between. Also fall back to the selector if
99+
// the default is billing-restricted and alternatives exist, so the user isn't dead-ended
100+
// on the restricted-action page.
101101
const isDefaultPersonal = !activePolicy || activePolicy.type === CONST.POLICY.TYPE.PERSONAL || !isPaidGroupPolicy(activePolicy);
102102
const hasMultipleNonPersonalWorkspaces = groupPoliciesWithChatEnabled.length > 1;
103103
const isDefaultBillingRestricted =
@@ -136,5 +136,5 @@ export default function useCreateReportAction({onCreateReport, groupPoliciesWith
136136
onCreateReport,
137137
]);
138138

139-
return {createReportAction, isVisible};
139+
return {createReport, isVisible};
140140
}

src/pages/Search/EmptySearchView.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {SearchScopeProvider} from '@components/Search/SearchScopeProvider';
1313
import type {SearchQueryJSON} from '@components/Search/types';
1414
import Text from '@components/Text';
1515
import TextLink from '@components/TextLink';
16-
import useCreateReportAction from '@hooks/useCreateReportAction';
16+
import useCreateReport from '@hooks/useCreateReport';
1717
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
1818
import useIsInLandscapeMode from '@hooks/useIsInLandscapeMode';
1919
import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset';
@@ -178,7 +178,7 @@ function EmptySearchViewContent({
178178
});
179179
};
180180

181-
const {createReportAction, isVisible: isCreateReportVisible} = useCreateReportAction({
181+
const {createReport, isVisible: isCreateReportVisible} = useCreateReport({
182182
onCreateReport: handleCreateWorkspaceReport,
183183
groupPoliciesWithChatEnabled,
184184
});
@@ -282,7 +282,7 @@ function EmptySearchViewContent({
282282
? [
283283
{
284284
buttonText: translate('quickAction.createReport'),
285-
buttonAction: createReportAction,
285+
buttonAction: createReport,
286286
success: true,
287287
},
288288
]

src/pages/inbox/sidebar/FABPopoverContent/menuItems/CreateReportMenuItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
3-
import useCreateReportAction from '@hooks/useCreateReportAction';
3+
import useCreateReport from '@hooks/useCreateReport';
44
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
55
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
66
import useLocalize from '@hooks/useLocalize';
@@ -94,7 +94,7 @@ function CreateReportMenuItem() {
9494
});
9595
};
9696

97-
const {createReportAction, isVisible} = useCreateReportAction({
97+
const {createReport, isVisible} = useCreateReport({
9898
onCreateReport: handleCreateWorkspaceReport,
9999
groupPoliciesWithChatEnabled,
100100
shouldHandleNavigationBack: false,
@@ -107,7 +107,7 @@ function CreateReportMenuItem() {
107107
pressableTestID={CONST.SENTRY_LABEL.FAB_MENU.CREATE_REPORT}
108108
icon={icons.Document}
109109
title={translate('report.newReport.createReport')}
110-
onPress={createReportAction}
110+
onPress={createReport}
111111
shouldCallAfterModalHide={shouldUseNarrowLayout}
112112
/>
113113
);

0 commit comments

Comments
 (0)