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 @@ -1541,7 +1541,6 @@ const CONST = {
INSIGHTS_COMPLIANCE: 'insightsCompliance',
NL_FILTERS: 'nlFilters',
SUPPORT_TICKET: 'supportTicket',
ANCHORED_FIELD_DROPDOWNS: 'anchoredFieldDropdowns',
RESIZABLE_TABLE_COLUMNS: 'resizableTableColumns',
PINNABLE_TABLE_COLUMNS: 'pinnableTableColumns',
COLLECT_DEPOSIT_ACCOUNTS: 'collectDepositAccounts',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import UserPills from '@components/UserPills';
import useAttendees from '@hooks/useAttendees';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';

import {enrichAndSortAttendees} from '@libs/AttendeeUtils';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
Expand Down Expand Up @@ -51,7 +50,6 @@ function AttendeeField({formattedAmountPerAttendee, isReadOnly, transactionID, a
const {translate, localeCompare, formatPhoneNumber} = useLocalize();
const personalDetailsList = usePersonalDetails();
const [loginToAccountIDMap] = useOnyx(ONYXKEYS.DERIVED.LOGIN_TO_ACCOUNT_ID_MAP);
const {isBetaEnabled} = usePermissions();
const {didConfirm} = useConfirmationFields();
const shouldDisplayAttendeesError = formError === 'violations.missingAttendees';

Expand Down Expand Up @@ -89,7 +87,7 @@ function AttendeeField({formattedAmountPerAttendee, isReadOnly, transactionID, a
// The dropdown writes the applied selection to the draft, so it stays closed once the expense is submitted and the
// draft is on its way out, as the category, tag and tax dropdowns do. A saved expense being edited keeps the full page,
// which saves once through the API with the expense's report and policy in hand.
const shouldOpenInDropdown = isBetaEnabled(CONST.BETAS.ANCHORED_FIELD_DROPDOWNS) && !!transactionID && !isReadOnly && !didConfirm && action !== CONST.IOU.ACTION.EDIT;
const shouldOpenInDropdown = !!transactionID && !isReadOnly && !didConfirm && action !== CONST.IOU.ACTION.EDIT;

if (shouldUseDropdownRows) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {SELECTION_LIST_POPOVER_HEADER_HEIGHT} from '@components/SelectionListPop
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import useReopenAfterReturn from '@hooks/useReopenAfterReturn';
import useThemeStyles from '@hooks/useThemeStyles';

Expand Down Expand Up @@ -66,7 +65,6 @@ function CategoryField({
}: CategoryFieldProps) {
const {shouldUseDropdownRows} = useExpenseFormLayout();
const {isEditingSplitBill, isScanRequest} = useConfirmationFields();
const {isBetaEnabled} = usePermissions();
const styles = useThemeStyles();
const {translate} = useLocalize();
const icons = useMemoizedLazyExpensifyIcons(['Sparkles']);
Expand Down Expand Up @@ -104,17 +102,15 @@ function CategoryField({
};

const canSaveFromThisForm = action !== CONST.IOU.ACTION.EDIT || isEditingSplitBill;
const canUseAnchoredFieldDropdowns = isBetaEnabled(CONST.BETAS.ANCHORED_FIELD_DROPDOWNS);
const isCreatingExpense = action === CONST.IOU.ACTION.CREATE;
// While creating, the list loads the categories itself and shows its own empty state, so it never needs the full page.
const canShowCategories = isCreatingExpense || hasEnabledCategories;
const shouldOpenInDropdown =
canUseAnchoredFieldDropdowns && !!transactionID && !!policy && !shouldNavigateToUpgradePath && !shouldSelectPolicy && canShowCategories && canSaveFromThisForm;
const shouldOpenInDropdown = !!transactionID && !!policy && !shouldNavigateToUpgradePath && !shouldSelectPolicy && canShowCategories && canSaveFromThisForm;
// The one condition both the row and the effect below open on, so the effect never asks the row to open a
// list it would refuse and fall back to the full page for.
const canOpenListInPlace = shouldOpenInDropdown && !isReadOnly && !didConfirm;
const canAddCategory = canCreateCategoryInSitu(policy, currentUserLogin);
const canOpenInDropdownAfterWorkspaceStep = canUseAnchoredFieldDropdowns && shouldUseDropdownRows && isCreatingExpense;
const canOpenInDropdownAfterWorkspaceStep = shouldUseDropdownRows && isCreatingExpense;

// The row sent the user to create or pick a workspace, and the upgrade step was told to only go back (`shouldReturnToConfirmation`).
// Once the form is focused again with a workspace, open the list in place. Backing out without one leaves nothing to list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {SELECTION_LIST_POPOVER_HEADER_HEIGHT} from '@components/SelectionListPop
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useOutstandingReports from '@hooks/useOutstandingReports';
import usePermissions from '@hooks/usePermissions';
import {usePersonalDetail} from '@hooks/usePersonalDetails';
import {useDerivedReportNameByReportID} from '@hooks/useReportAttributes';

Expand Down Expand Up @@ -49,7 +48,6 @@ type ReportFieldProps = {
function ReportField({selectedParticipants, iouType, reportID, reportActionID, action, transactionID, isPerDiemRequest, isPolicyExpenseChat}: ReportFieldProps) {
const {shouldUseDropdownRows} = useExpenseFormLayout();
const {translate, localeCompare} = useLocalize();
const {isBetaEnabled} = usePermissions();
const ownerAccountID = selectedParticipants?.at(0)?.ownerAccountID;
const [ownerPersonalDetail] = usePersonalDetail(ownerAccountID);

Expand Down Expand Up @@ -124,7 +122,7 @@ function ReportField({selectedParticipants, iouType, reportID, reportActionID, a
const shouldReportBeEditable = (!mayHideListOptions || shouldReportFieldBeEditable(outstandingReports, selectedReportID, isUnreported)) && !isMoneyRequestReport(reportID);
// Editing a saved expense's report and moving a per diem expense both navigate on from the list (to the report, or to
// the destination step when the workspace changes), so those keep the full page.
const shouldOpenInDropdown = isBetaEnabled(CONST.BETAS.ANCHORED_FIELD_DROPDOWNS) && !!transactionID && shouldReportBeEditable && action !== CONST.IOU.ACTION.EDIT && !isPerDiemRequest;
const shouldOpenInDropdown = !!transactionID && shouldReportBeEditable && action !== CONST.IOU.ACTION.EDIT && !isPerDiemRequest;

const openReportPage = () => {
if (!transactionID || !selectedReportID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {useConfirmationFields} from '@components/MoneyRequestConfirmationFields/
import {SELECTION_LIST_POPOVER_HEADER_HEIGHT} from '@components/SelectionListPopoverHeader';

import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import useThemeStyles from '@hooks/useThemeStyles';

import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
Expand Down Expand Up @@ -69,7 +68,6 @@ function TagFields({
}: TagFieldsProps) {
const {shouldUseDropdownRows} = useExpenseFormLayout();
const {isEditingSplitBill} = useConfirmationFields();
const {isBetaEnabled} = usePermissions();
const styles = useThemeStyles();
const {translate} = useLocalize();
const shouldDisplayTagError = formError === 'violations.tagOutOfPolicy';
Expand All @@ -84,7 +82,7 @@ function TagFields({
const canSaveFromThisForm = action !== CONST.IOU.ACTION.EDIT || isEditingSplitBill;
const isCreatingExpense = action === CONST.IOU.ACTION.CREATE;
const canShowTags = isCreatingExpense || getCountOfEnabledTagsOfList(policyTagList.tags) > 0;
const shouldOpenInDropdown = isBetaEnabled(CONST.BETAS.ANCHORED_FIELD_DROPDOWNS) && !!transactionID && !!policy && canSaveFromThisForm && !hasDependentTags && canShowTags;
const shouldOpenInDropdown = !!transactionID && !!policy && canSaveFromThisForm && !hasDependentTags && canShowTags;

const openTagPage = () => {
if (!transactionID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {SELECTION_LIST_POPOVER_HEADER_HEIGHT} from '@components/SelectionListPop
import {useCurrencyListActions} from '@hooks/useCurrencyList';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import useThemeStyles from '@hooks/useThemeStyles';

import {setMoneyRequestTaxAmount} from '@libs/actions/IOU/MoneyRequest';
Expand Down Expand Up @@ -63,7 +62,6 @@ function TaxFields({policy, policyForMovingExpenses, iouCurrencyCode, canModifyT
const {translate, preferredLocale} = useLocalize();
const {convertToDisplayString, getCurrencyDecimals, getCurrencySymbol} = useCurrencyListActions();
const {isEditingSplitBill, onTaxAmountEmptyChange} = useConfirmationFields();
const {isBetaEnabled} = usePermissions();
const numberFormRef = useRef<NumberWithSymbolFormRef | null>(null);

const taxSlice = useTransactionSelector(transactionID, taxSliceSelector);
Expand Down Expand Up @@ -147,7 +145,7 @@ function TaxFields({policy, policyForMovingExpenses, iouCurrencyCode, canModifyT

const canSaveFromThisForm = action !== CONST.IOU.ACTION.EDIT || isEditingSplitBill;
const hasEnabledTaxRates = getEnabledTaxRateCount(taxRates?.taxes ?? {}) > 0;
const shouldOpenInDropdown = isBetaEnabled(CONST.BETAS.ANCHORED_FIELD_DROPDOWNS) && !!transactionID && !!taxRatesPolicy && canSaveFromThisForm && hasEnabledTaxRates;
const shouldOpenInDropdown = !!transactionID && !!taxRatesPolicy && canSaveFromThisForm && hasEnabledTaxRates;

const openTaxRatePage = () => {
if (!transactionID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ import waitForBatchedUpdates from '../../../utils/waitForBatchedUpdates';
jest.mock('@hooks/useLocalize', () => () => ({translate: (key: string) => key, localeCompare: (a: string, b: string) => a.localeCompare(b), formatPhoneNumber: (value: string) => value}));
jest.mock('@libs/Navigation/Navigation', () => ({navigate: jest.fn()}));

let mockIsAnchoredDropdownsBetaEnabled = true;
jest.mock('@hooks/usePermissions', () => () => ({
isBetaEnabled: (beta: string) => mockIsAnchoredDropdownsBetaEnabled && beta === jest.requireActual<{default: typeof CONST}>('@src/CONST').default.BETAS.ANCHORED_FIELD_DROPDOWNS,
}));

// Records what the row decided and renders its list straight away, so each test can read both without pressing anything.
let mockShouldOpenInDropdown: boolean | undefined;
type ExpenseFieldDropdownMockProps = Pick<ComponentProps<typeof ExpenseFieldDropdown>, 'shouldOpenInDropdown' | 'renderDropdown'>;
Expand Down Expand Up @@ -92,7 +87,6 @@ describe('AttendeeField', () => {
});

beforeEach(async () => {
mockIsAnchoredDropdownsBetaEnabled = true;
mockShouldOpenInDropdown = undefined;
mockDropdownTransactionID = undefined;
await Onyx.clear();
Expand All @@ -101,7 +95,7 @@ describe('AttendeeField', () => {
});

it('opens the attendee list in place while creating an expense', async () => {
// Given a draft expense on the create form, with the anchored dropdowns beta on
// Given a draft expense on the create form
// When the form renders the attendees row
renderAttendeesRow();

Expand All @@ -112,19 +106,6 @@ describe('AttendeeField', () => {
expect(mockDropdownTransactionID).toBe(TRANSACTION_ID);
});

it('keeps the full-page selector when the beta is off', async () => {
// Given the same draft, for a user without the anchored dropdowns beta
mockIsAnchoredDropdownsBetaEnabled = false;

// When the form renders the attendees row
renderAttendeesRow();

// Then the row opens the full-page selector as before
await waitFor(() => {
expect(mockShouldOpenInDropdown).toBe(false);
});
});

it('keeps the full-page selector for a saved expense being edited', async () => {
// Given a saved expense whose attendees are being edited, which the dropdown cannot save since it writes to the draft
// When the form renders the attendees row
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ jest.mock('@components/MenuItemWithTopDescription', () => {

jest.mock('@hooks/useLocalize', () => () => ({translate: (key: string) => key}));
jest.mock('@hooks/useThemeStyles', () => () => ({}));
// Only the anchored dropdowns beta, so the tests that render the plain menu row keep every other beta off.
jest.mock('@hooks/usePermissions', () => () => ({
isBetaEnabled: (beta: string) => beta === jest.requireActual<{default: typeof CONST}>('@src/CONST').default.BETAS.ANCHORED_FIELD_DROPDOWNS,
}));

let mockIsFocused = true;
// Mirrors `useFocusEffect`: runs the effect while the screen is focused, and again whenever the effect changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ jest.mock('@hooks/useLocalize', () => () => ({translate: (key: string) => key, l
jest.mock('@libs/Navigation/Navigation', () => ({navigate: jest.fn(), navigationRef: {getCurrentRoute: jest.fn(() => undefined)}}));
jest.mock('@hooks/useReportAttributes', () => ({useDerivedReportNameByReportID: () => undefined}));

let mockIsAnchoredDropdownsBetaEnabled = true;
jest.mock('@hooks/usePermissions', () => () => ({
isBetaEnabled: (beta: string) => mockIsAnchoredDropdownsBetaEnabled && beta === jest.requireActual<{default: typeof CONST}>('@src/CONST').default.BETAS.ANCHORED_FIELD_DROPDOWNS,
}));

// The reports the user could move the expense to. The row only offers a choice when there is one.
let mockOutstandingReports: Report[] = [];
jest.mock('@hooks/useOutstandingReports', () => () => mockOutstandingReports);
Expand Down Expand Up @@ -103,7 +98,6 @@ describe('ReportField', () => {
});

beforeEach(async () => {
mockIsAnchoredDropdownsBetaEnabled = true;
// Two reports the expense could go on, which leaves a choice to make whether or not the list offers a new report.
mockOutstandingReports = [outstandingReport, otherOutstandingReport];
mockShouldOpenInDropdown = undefined;
Expand All @@ -120,7 +114,7 @@ describe('ReportField', () => {
});

it('opens the report list in place while creating an expense', async () => {
// Given a workspace with two outstanding reports the expense could go on, and the anchored dropdowns beta on
// Given a workspace with two outstanding reports the expense could go on
// When the expense form renders the report row
renderReportRow();

Expand All @@ -131,19 +125,6 @@ describe('ReportField', () => {
expect(mockDropdownTransactionID).toBe(TRANSACTION_ID);
});

it('keeps the full-page selector when the beta is off', async () => {
// Given the same workspace, for a user without the anchored dropdowns beta
mockIsAnchoredDropdownsBetaEnabled = false;

// When the form renders the report row
renderReportRow();

// Then the row opens the full-page selector as before
await waitFor(() => {
expect(mockShouldOpenInDropdown).toBe(false);
});
});

it('opens the list when the workspace has no report open yet', async () => {
// Given a workspace with no outstanding report, where the expense would go on a new report
mockOutstandingReports = [];
Expand Down Expand Up @@ -172,21 +153,6 @@ describe('ReportField', () => {
expect(mockIsInteractive).toBe(true);
});

it('opens the full-page selector when the workspace has only one report and the beta is off', async () => {
// Given a workspace with one outstanding report, for a user without the anchored dropdowns beta
mockIsAnchoredDropdownsBetaEnabled = false;
mockOutstandingReports = [outstandingReport];

// When the form renders the report row
renderReportRow();

// Then the row can be changed, so the user can pick a new report instead, through the full-page selector
await waitFor(() => {
expect(mockIsInteractive).toBe(true);
});
expect(mockShouldOpenInDropdown).toBe(false);
});

it('keeps the row locked when editing an expense on the only report it can go on', async () => {
// Given a saved expense on a report, in a workspace with no other outstanding report. The list can hide its new
// report option for an edit, which would leave nothing but the report the expense is already on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ jest.mock('@libs/Navigation/Navigation', () => ({navigate: jest.fn()}));
// The new-row flash needs a screen's transition context, which the row is rendered without here.
jest.mock('@components/MoneyRequestConfirmationList/sections/useFieldRowHighlightStyle', () => () => ({}));

let mockIsAnchoredDropdownsBetaEnabled = true;
jest.mock('@hooks/usePermissions', () => () => ({
isBetaEnabled: (beta: string) => mockIsAnchoredDropdownsBetaEnabled && beta === jest.requireActual<{default: typeof CONST}>('@src/CONST').default.BETAS.ANCHORED_FIELD_DROPDOWNS,
}));

// Records what the row decided and renders its list straight away, so each test can read both without pressing anything.
let mockShouldOpenInDropdown: boolean | undefined;
jest.mock('@components/MoneyRequestConfirmationList/sections/ExpenseFieldDropdown', () => {
Expand Down Expand Up @@ -120,7 +115,6 @@ describe('TagFields', () => {
});

beforeEach(async () => {
mockIsAnchoredDropdownsBetaEnabled = true;
mockShouldOpenInDropdown = undefined;
mockTagListIndexes.length = 0;
jest.mocked(Navigation.navigate).mockClear();
Expand All @@ -134,7 +128,7 @@ describe('TagFields', () => {
};

it('opens the tag list in place while creating an expense', async () => {
// Given a workspace with independent tag lists and the anchored dropdowns beta on
// Given a workspace with independent tag lists
await givenPolicyTags(independentTags);

// When the expense form renders a tag row
Expand Down Expand Up @@ -173,20 +167,6 @@ describe('TagFields', () => {
});
});

it('keeps the full-page selector when the beta is off', async () => {
// Given a workspace with independent tags, for a user without the anchored dropdowns beta
mockIsAnchoredDropdownsBetaEnabled = false;
await givenPolicyTags(independentTags);

// When the form renders a tag row
renderTagRow();

// Then the row opens the full-page selector as before
await waitFor(() => {
expect(mockShouldOpenInDropdown).toBe(false);
});
});

it('does not open the list on a read-only or confirmed form', async () => {
// Given a workspace with independent tags
await givenPolicyTags(independentTags);
Expand Down
Loading
Loading