Skip to content

Commit 29a3ca8

Browse files
committed
debt(Expense): remove legacy flow
1 parent 4fffa73 commit 29a3ca8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+68
-8078
lines changed

components/AccountingCategorySelect.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,7 @@ export const getCategoryLabel = (
174174
/**
175175
* Returns true if the category is supported for the given expense type. Host admins can select any category.
176176
*/
177-
export const isSupportedExpenseCategory = (
178-
expenseType: ExpenseType,
179-
category: AccountingCategory,
180-
isHostAdmin: boolean,
181-
) => {
177+
const isSupportedExpenseCategory = (expenseType: ExpenseType, category: AccountingCategory, isHostAdmin: boolean) => {
182178
return (
183179
category?.kind === AccountingCategoryKind.EXPENSE &&
184180
(isHostAdmin || !category?.expensesTypes || category.expensesTypes.includes(expenseType))

components/I18nAddressFields.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ const wrangleAddressData = addressInfo => {
6363
return addressFormFields;
6464
};
6565

66-
export const serializeAddress = address => {
67-
return Object.keys(address)
68-
.sort()
69-
.map(k => address[k])
70-
.join('\n');
71-
};
72-
7366
/** Upon changing selectedCountry, if previous address fields are no longer needed,
7467
* it clears them i.e. changing from Canada to Germany in the Expense form we no
7568
* longer need 'zone' in our payeeLocation.address object.

components/collective-navbar/ActionsMenu.js

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@ import { AttachMoney } from '@styled-icons/material/AttachMoney';
88
import { Settings } from '@styled-icons/material/Settings';
99
import { Stack } from '@styled-icons/remix-line/Stack';
1010
import { pickBy } from 'lodash';
11-
import { useRouter } from 'next/router';
1211
import { FormattedMessage } from 'react-intl';
1312
import styled, { css } from 'styled-components';
1413

1514
import { getContributeRoute } from '../../lib/collective';
16-
import { isSupportedExpenseType } from '../../lib/expenses';
17-
import { ExpenseType } from '../../lib/graphql/types/v2/graphql';
18-
import { PREVIEW_FEATURE_KEYS } from '../../lib/preview-features';
1915
import { getCollectivePageRoute, getDashboardRoute } from '../../lib/url-helpers';
20-
import { parseToBoolean } from '@/lib/utils';
2116

2217
import ActionButton from '../ActionButton';
2318
import AddFundsBtn from '../AddFundsBtn';
@@ -183,16 +178,6 @@ const CollectiveNavbarActionsMenu = ({
183178
const enabledCTAs = Object.keys(pickBy(callsToAction, Boolean));
184179
const isEmpty = enabledCTAs.length < 1;
185180
const hasOnlyOneHiddenCTA = enabledCTAs.length === 1 && hiddenActionForNonMobile === enabledCTAs[0];
186-
const router = useRouter();
187-
188-
const newExpenseFlowOptedOut = parseToBoolean(router?.query?.forceLegacyFlow);
189-
const isNewGrantFlowEnabled =
190-
!newExpenseFlowOptedOut && LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW);
191-
192-
const isNewExpenseFlowEnabled =
193-
!newExpenseFlowOptedOut &&
194-
LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW) &&
195-
(!isSupportedExpenseType(collective, ExpenseType.GRANT) || isNewGrantFlowEnabled);
196181

197182
// Do not render the menu if there are no available CTAs
198183
if (isEmpty) {
@@ -241,33 +226,17 @@ const CollectiveNavbarActionsMenu = ({
241226
)}
242227
{callsToAction.hasSubmitExpense && (
243228
<MenuItem isHiddenOnMobile={hiddenActionForNonMobile === NAVBAR_ACTION_TYPE.SUBMIT_EXPENSE}>
244-
{isNewExpenseFlowEnabled ? (
245-
<StyledLink onClick={onOpenSubmitExpenseModalClick}>
246-
<Container p={ITEM_PADDING}>
247-
<Receipt size="20px" />
248-
<FormattedMessage id="ExpenseForm.Submit" defaultMessage="Submit expense" />
249-
</Container>
250-
</StyledLink>
251-
) : (
252-
<StyledLink
253-
data-cy="submit-expense-dropdown"
254-
as={Link}
255-
href={`${getCollectivePageRoute(collective)}/expenses/new?forceLegacyFlow=true`}
256-
>
257-
<Container p={ITEM_PADDING}>
258-
<Receipt size="20px" />
259-
<FormattedMessage id="ExpenseForm.Submit" defaultMessage="Submit expense" />
260-
</Container>
261-
</StyledLink>
262-
)}
229+
<StyledLink onClick={onOpenSubmitExpenseModalClick}>
230+
<Container p={ITEM_PADDING}>
231+
<Receipt size="20px" />
232+
<FormattedMessage id="ExpenseForm.Submit" defaultMessage="Submit expense" />
233+
</Container>
234+
</StyledLink>
263235
</MenuItem>
264236
)}
265237
{callsToAction.hasRequestGrant && (
266238
<MenuItem py={1} isHiddenOnMobile={hiddenActionForNonMobile === NAVBAR_ACTION_TYPE.REQUEST_GRANT}>
267-
<StyledLink
268-
as={Link}
269-
href={`${getCollectivePageRoute(collective)}/${isNewGrantFlowEnabled ? 'grants' : 'expenses'}/new`}
270-
>
239+
<StyledLink as={Link} href={`${getCollectivePageRoute(collective)}/grants/new`}>
271240
<Container p={ITEM_PADDING}>
272241
<MoneyCheckAlt size="20px" />
273242
<FormattedMessage id="ExpenseForm.Type.Request" defaultMessage="Request Grant" />

components/collective-navbar/index.js

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ import EXPENSE_TYPE from '../../lib/constants/expenseTypes';
2323
import roles from '../../lib/constants/roles';
2424
import { isSupportedExpenseType } from '../../lib/expenses';
2525
import { API_V2_CONTEXT, gql } from '../../lib/graphql/helpers';
26-
import { ExpenseType } from '../../lib/graphql/types/v2/graphql';
2726
import useGlobalBlur from '../../lib/hooks/useGlobalBlur';
2827
import useLoggedInUser from '../../lib/hooks/useLoggedInUser';
29-
import { PREVIEW_FEATURE_KEYS } from '../../lib/preview-features';
3028
import { getCollectivePageRoute, getDashboardRoute } from '../../lib/url-helpers';
3129

3230
import ActionButton from '../ActionButton';
@@ -508,12 +506,6 @@ const CollectiveNavbar = ({
508506

509507
const loading = isLoading || dataLoading;
510508

511-
const isNewGrantFlowEnabled = LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW);
512-
513-
const isNewExpenseFlowEnabled =
514-
LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW) &&
515-
(!isSupportedExpenseType(collective, ExpenseType.GRANT) || isNewGrantFlowEnabled);
516-
517509
const isAllowedAddFunds = Boolean(data?.account?.permissions?.addFunds?.allowed);
518510
const sections = React.useMemo(() => {
519511
return sectionsFromParent || getFilteredSectionsForCollective(collective, isAdmin, isHostAdmin);
@@ -531,23 +523,11 @@ const CollectiveNavbar = ({
531523
...callsToAction,
532524
};
533525
const actionsArray = Object.keys(pickBy(callsToAction, Boolean));
534-
const mainAction = getMainAction(
535-
collective,
536-
actionsArray,
537-
LoggedInUser,
538-
isNewExpenseFlowEnabled,
539-
isNewGrantFlowEnabled,
540-
() => setIsSubmitExpenseModalOpen(true),
541-
);
526+
const mainAction = getMainAction(collective, actionsArray, LoggedInUser, () => setIsSubmitExpenseModalOpen(true));
542527
const secondAction =
543528
actionsArray.length === 2 &&
544-
getMainAction(
545-
collective,
546-
without(actionsArray, mainAction?.type),
547-
LoggedInUser,
548-
isNewExpenseFlowEnabled,
549-
isNewGrantFlowEnabled,
550-
() => setIsSubmitExpenseModalOpen(true),
529+
getMainAction(collective, without(actionsArray, mainAction?.type), LoggedInUser, () =>
530+
setIsSubmitExpenseModalOpen(true),
551531
);
552532
const navbarRef = useRef(undefined);
553533
const mainContainerRef = useRef(undefined);

components/dashboard/sections/expenses/ReceivedExpenses.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import {
1414
ExpenseType,
1515
PayoutMethodType,
1616
} from '../../../../lib/graphql/types/v2/schema';
17-
import useLoggedInUser from '../../../../lib/hooks/useLoggedInUser';
1817
import useQueryFilter from '../../../../lib/hooks/useQueryFilter';
19-
import { PREVIEW_FEATURE_KEYS } from '../../../../lib/preview-features';
2018
import { i18nExpenseType } from '@/lib/i18n/expense';
2119
import { sortSelectOptions } from '@/lib/utils';
2220

@@ -111,7 +109,6 @@ const ROUTE_PARAMS = ['slug', 'section', 'subpath'];
111109
const ReceivedExpenses = ({ accountSlug }: DashboardSectionProps) => {
112110
const router = useRouter();
113111
const [isExpenseFlowOpen, setIsExpenseFlowOpen] = React.useState(false);
114-
const { LoggedInUser } = useLoggedInUser();
115112

116113
const {
117114
data: metadata,
@@ -161,9 +158,6 @@ const ReceivedExpenses = ({ accountSlug }: DashboardSectionProps) => {
161158
context: API_V2_CONTEXT,
162159
});
163160

164-
const hasNewSubmitExpenseFlow =
165-
LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW) || router.query.newExpenseFlowEnabled;
166-
167161
const pageRoute = `/dashboard/${accountSlug}/expenses`;
168162

169163
return (
@@ -173,11 +167,9 @@ const ReceivedExpenses = ({ accountSlug }: DashboardSectionProps) => {
173167
title={<FormattedMessage defaultMessage="Received Expenses" id="1c0Y31" />}
174168
description={<FormattedMessage defaultMessage="Expenses submitted to your account." id="0I3Lbj" />}
175169
actions={
176-
hasNewSubmitExpenseFlow ? (
177-
<Button onClick={() => setIsExpenseFlowOpen(true)} size="sm" className="gap-1">
178-
<FormattedMessage defaultMessage="New expense" id="pNn/g+" />
179-
</Button>
180-
) : null
170+
<Button onClick={() => setIsExpenseFlowOpen(true)} size="sm" className="gap-1">
171+
<FormattedMessage defaultMessage="New expense" id="pNn/g+" />
172+
</Button>
181173
}
182174
/>
183175
{isSelfHosted && (

components/dashboard/sections/expenses/SubmittedExpenses.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { defineMessage, FormattedMessage } from 'react-intl';
77
import { API_V2_CONTEXT } from '../../../../lib/graphql/helpers';
88
import useLoggedInUser from '../../../../lib/hooks/useLoggedInUser';
99
import useQueryFilter from '../../../../lib/hooks/useQueryFilter';
10-
import { PREVIEW_FEATURE_KEYS } from '../../../../lib/preview-features';
1110
import type { FilterComponentConfigs } from '@/lib/filters/filter-types';
1211
import type { Currency } from '@/lib/graphql/types/v2/schema';
1312
import { ExpenseType } from '@/lib/graphql/types/v2/schema';
@@ -94,9 +93,6 @@ const SubmittedExpenses = ({ accountSlug }: DashboardSectionProps) => {
9493
accountingCategoryKinds: ExpenseAccountingCategoryKinds,
9594
};
9695

97-
const hasNewSubmitExpenseFlow =
98-
LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW) || router.query.newExpenseFlowEnabled;
99-
10096
const pageRoute = `/dashboard/${accountSlug}/submitted-expenses`;
10197

10298
if (error) {
@@ -112,18 +108,16 @@ const SubmittedExpenses = ({ accountSlug }: DashboardSectionProps) => {
112108
<FormattedMessage defaultMessage="Expenses that you have submitted to other accounts." id="aKfm6V" />
113109
}
114110
actions={
115-
hasNewSubmitExpenseFlow ? (
116-
<Button
117-
onClick={() => {
118-
setDuplicateExpenseId(null);
119-
setIsExpenseFlowOpen(true);
120-
}}
121-
size="sm"
122-
className="gap-1"
123-
>
124-
<FormattedMessage defaultMessage="New expense" id="pNn/g+" />
125-
</Button>
126-
) : null
111+
<Button
112+
onClick={() => {
113+
setDuplicateExpenseId(null);
114+
setIsExpenseFlowOpen(true);
115+
}}
116+
size="sm"
117+
className="gap-1"
118+
>
119+
<FormattedMessage defaultMessage="New expense" id="pNn/g+" />
120+
</Button>
127121
}
128122
/>
129123
<Filterbar {...queryFilter} meta={filterMeta} />

components/expenses/AddNewAttachedFilesButton.tsx

Lines changed: 0 additions & 86 deletions
This file was deleted.

components/expenses/ConfirmOCRValues.tsx

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)