From fff377d26c133f24b00cc5165ca78cd704292588 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 5 Feb 2026 04:51:39 +0530 Subject: [PATCH 1/6] update getMoneyRequestOptions to accept betas. Signed-off-by: krishna2323 --- src/components/ReportWelcomeText.tsx | 3 +- src/libs/QuickActionUtils.ts | 6 +- src/libs/ReportUtils.ts | 9 +- .../AttachmentPickerWithMenuItems.tsx | 3 +- .../ReportActionCompose.tsx | 5 +- .../FloatingActionButtonAndPopover.tsx | 2 +- .../workspace/AccessOrNotFoundWrapper.tsx | 11 ++- tests/perf-test/ReportUtils.perf-test.ts | 2 +- tests/unit/QuickActionUtilsTest.ts | 28 +++--- tests/unit/ReportUtilsTest.ts | 96 +++++++++---------- 10 files changed, 88 insertions(+), 77 deletions(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 0278ccc135422..e132c9ea1c1f2 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -65,9 +65,10 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) { const isSelfDM = isSelfDMReportUtils(report); const isInvoiceRoom = isInvoiceRoomReportUtils(report); const isSystemChat = isSystemChatReportUtils(report); + const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true}); const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM || isSystemChat); const participantAccountIDs = getParticipantsAccountIDsForDisplay(report, undefined, true, true, reportMetadata); - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, policy, participantAccountIDs, isReportArchived, isRestrictedToPreferredPolicy); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, policy, participantAccountIDs,betas, isReportArchived, isRestrictedToPreferredPolicy); const policyName = getPolicyName({report}); const filteredOptions = moneyRequestOptions.filter( diff --git a/src/libs/QuickActionUtils.ts b/src/libs/QuickActionUtils.ts index f26ef936b1ffa..20588d33201c5 100644 --- a/src/libs/QuickActionUtils.ts +++ b/src/libs/QuickActionUtils.ts @@ -1,10 +1,11 @@ import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; -import type {Policy, Report} from '@src/types/onyx'; +import type {Beta, Policy, Report} from '@src/types/onyx'; import type {QuickActionName} from '@src/types/onyx/QuickAction'; import type QuickAction from '@src/types/onyx/QuickAction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type IconAsset from '@src/types/utils/IconAsset'; +import type { OnyxEntry } from 'react-native-onyx'; import getIconForAction from './getIconForAction'; import {getPerDiemCustomUnit} from './PolicyUtils'; import {canCreateRequest} from './ReportUtils'; @@ -99,6 +100,7 @@ const isQuickActionAllowed = ( quickActionReport: Report | undefined, quickActionPolicy: Policy | undefined, isReportArchived: boolean | undefined, + betas: OnyxEntry, isRestrictedToPreferredPolicy = false, ) => { if (quickAction?.action === CONST.QUICK_ACTIONS.PER_DIEM) { @@ -117,7 +119,7 @@ const isQuickActionAllowed = ( if (isReportHasManagerMCTest) { return false; } - return canCreateRequest(quickActionReport, quickActionPolicy, iouType, isReportArchived, isRestrictedToPreferredPolicy); + return canCreateRequest(quickActionReport, quickActionPolicy, iouType, isReportArchived, betas, isRestrictedToPreferredPolicy); } return true; }; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c6ac51810132c..46cd94144739d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -9978,6 +9978,7 @@ function getMoneyRequestOptions( report: OnyxEntry, policy: OnyxEntry, reportParticipants: number[], + betas: OnyxEntry, filterDeprecatedTypes = false, isReportArchived = false, isRestrictedToPreferredPolicy = false, @@ -10009,7 +10010,7 @@ function getMoneyRequestOptions( if ( canRequestMoney(report, policy, otherParticipants) && reportParticipants.some((accountID) => accountID === CONST.ACCOUNT_ID.MANAGER_MCTEST) && - Permissions.isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST, allBetas) + Permissions.isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST, betas) ) { return [CONST.IOU.TYPE.SUBMIT]; } @@ -10095,10 +10096,11 @@ function temporary_getMoneyRequestOptions( report: OnyxEntry, policy: OnyxEntry, reportParticipants: number[], + betas: OnyxEntry, isReportArchived = false, isRestrictedToPreferredPolicy = false, ): Array> { - return getMoneyRequestOptions(report, policy, reportParticipants, true, isReportArchived, isRestrictedToPreferredPolicy) as Array< + return getMoneyRequestOptions(report, policy, reportParticipants, betas, true, isReportArchived, isRestrictedToPreferredPolicy) as Array< Exclude >; } @@ -10308,6 +10310,7 @@ function canCreateRequest( policy: OnyxEntry, iouType: ValueOf, isReportArchived: boolean | undefined, + betas: OnyxEntry, isRestrictedToPreferredPolicy = false, ): boolean { const participantAccountIDs = Object.keys(report?.participants ?? {}).map(Number); @@ -10316,7 +10319,7 @@ function canCreateRequest( return false; } - const requestOptions = getMoneyRequestOptions(report, policy, participantAccountIDs, false, isReportArchived, isRestrictedToPreferredPolicy); + const requestOptions = getMoneyRequestOptions(report, policy, participantAccountIDs, betas, false, isReportArchived, isRestrictedToPreferredPolicy); requestOptions.push(CONST.IOU.TYPE.CREATE); return requestOptions.includes(iouType); diff --git a/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index 5a27118e4716e..171fbceb244ac 100644 --- a/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -290,7 +290,7 @@ function AttachmentPickerWithMenuItems({ ], }; - const moneyRequestOptionsList = temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? [], isReportArchived, isRestrictedToPreferredPolicy).map( + const moneyRequestOptionsList = temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? [], betas, isReportArchived, isRestrictedToPreferredPolicy).map( (option) => options[option], ); @@ -308,6 +308,7 @@ function AttachmentPickerWithMenuItems({ showDelegateNoAccessModal, translate, icons, + betas, ]); const createReportOption: PopoverMenuItem[] = useMemo(() => { diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 96145167da47e..736d3ade0f34f 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -159,6 +159,7 @@ function ReportActionCompose({ const [initialModalState] = useOnyx(ONYXKEYS.MODAL, {canBeMissing: true}); const [newParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`, {canBeMissing: true}); const [draftComment] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`, {canBeMissing: true}); + const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true}); const shouldFocusComposerOnScreenFocus = shouldFocusInputOnScreenFocus || !!draftComment; @@ -250,11 +251,11 @@ function ReportActionCompose({ const shouldDisplayDualDropZone = useMemo(() => { const parentReport = getParentReport(report); const isSettledOrApproved = isSettled(report) || isSettled(parentReport) || isReportApproved({report}) || isReportApproved({report: parentReport}); - const hasMoneyRequestOptions = !!temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs, isReportArchived, isRestrictedToPreferredPolicy).length; + const hasMoneyRequestOptions = !!temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs, betas, isReportArchived, isRestrictedToPreferredPolicy).length; const canModifyReceipt = shouldAddOrReplaceReceipt && !isSettledOrApproved; const isRoomOrGroupChat = isChatRoom(report) || isGroupChat(report); return !isRoomOrGroupChat && (canModifyReceipt || hasMoneyRequestOptions) && !isInvoiceReport(report); - }, [shouldAddOrReplaceReceipt, report, reportParticipantIDs, policy, isReportArchived, isRestrictedToPreferredPolicy]); + }, [shouldAddOrReplaceReceipt, report, reportParticipantIDs, policy, isReportArchived, isRestrictedToPreferredPolicy, betas]); // Placeholder to display in the chat input. const inputPlaceholder = useMemo(() => { diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index 698ae921ffbd3..c0b21918edeab 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -462,7 +462,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref }; if (quickAction?.action && quickActionReport) { - if (!isQuickActionAllowed(quickAction, quickActionReport, quickActionPolicy, isReportArchived, isRestrictedToPreferredPolicy)) { + if (!isQuickActionAllowed(quickAction, quickActionReport, quickActionPolicy, isReportArchived, allBetas, isRestrictedToPreferredPolicy)) { return []; } const onSelected = () => { diff --git a/src/pages/workspace/AccessOrNotFoundWrapper.tsx b/src/pages/workspace/AccessOrNotFoundWrapper.tsx index bd2df9550c75b..b0d8b144b7edc 100644 --- a/src/pages/workspace/AccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AccessOrNotFoundWrapper.tsx @@ -22,7 +22,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; -import type {Report} from '@src/types/onyx'; +import type {Beta, Report} from '@src/types/onyx'; import type {PolicyFeatureName} from '@src/types/onyx/Policy'; import type Policy from '@src/types/onyx/Policy'; import callOrReturn from '@src/types/utils/callOrReturn'; @@ -37,6 +37,7 @@ const ACCESS_VARIANTS = { login: string, report: OnyxEntry, allPolicies: NonNullable> | null, + betas: OnyxEntry, iouType?: IOUType, isReportArchived?: boolean, isRestrictedToPreferredPolicy?: boolean, @@ -45,7 +46,7 @@ const ACCESS_VARIANTS = { isValidMoneyRequestType(iouType) && // Allow the user to submit the expense if we are submitting the expense in global menu or the report can create the expense - (isEmptyObject(report?.reportID) || canCreateRequest(report, policy, iouType, isReportArchived, isRestrictedToPreferredPolicy)) && + (isEmptyObject(report?.reportID) || canCreateRequest(report, policy, iouType, isReportArchived, betas, isRestrictedToPreferredPolicy)) && (iouType !== CONST.IOU.TYPE.INVOICE || canSendInvoice(allPolicies, login)), } as const satisfies Record< string, @@ -54,6 +55,7 @@ const ACCESS_VARIANTS = { login: string, report: Report, allPolicies: NonNullable> | null, + betas: OnyxEntry, iouType?: IOUType, isArchivedReport?: boolean, isRestrictedToPreferredPolicy?: boolean, @@ -148,6 +150,7 @@ function AccessOrNotFoundWrapper({ const [isLoadingReportData = true] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA, {canBeMissing: true}); const {login = ''} = useCurrentUserPersonalDetails(); const {isRestrictedToPreferredPolicy} = usePreferredPolicy(); + const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true}); const isPolicyIDInRoute = !!policyID?.length; const isMoneyRequest = !!iouType && isValidMoneyRequestType(iouType); const isFromGlobalCreate = !!reportID && isEmptyObject(report?.reportID); @@ -174,9 +177,9 @@ function AccessOrNotFoundWrapper({ const isPageAccessible = accessVariants.reduce((acc, variant) => { const accessFunction = ACCESS_VARIANTS[variant]; if (variant === CONST.IOU.ACCESS_VARIANTS.CREATE) { - return acc && accessFunction(policy, login, report, allPolicies ?? null, iouType, isReportArchived, isRestrictedToPreferredPolicy); + return acc && accessFunction(policy, login, report, allPolicies ?? null, betas, iouType, isReportArchived, isRestrictedToPreferredPolicy); } - return acc && accessFunction(policy, login, report, allPolicies ?? null, iouType, isReportArchived); + return acc && accessFunction(policy, login, report, allPolicies ?? null, betas, iouType, isReportArchived); }, true); const isPolicyNotAccessible = !isPolicyAccessible(policy, login); diff --git a/tests/perf-test/ReportUtils.perf-test.ts b/tests/perf-test/ReportUtils.perf-test.ts index 6d01a54d3155b..dd4d93f326f4f 100644 --- a/tests/perf-test/ReportUtils.perf-test.ts +++ b/tests/perf-test/ReportUtils.perf-test.ts @@ -204,7 +204,7 @@ describe('ReportUtils', () => { const reportParticipants = Array.from({length: 1000}, (v, i) => i + 1); await waitForBatchedUpdates(); - await measureFunction(() => temporary_getMoneyRequestOptions(report, policy, reportParticipants)); + await measureFunction(() => temporary_getMoneyRequestOptions(report, policy, reportParticipants, [CONST.BETAS.ALL])); }); test('[ReportUtils] getWorkspaceChat on 1k policies', async () => { diff --git a/tests/unit/QuickActionUtilsTest.ts b/tests/unit/QuickActionUtilsTest.ts index cb5bb3f317eae..a7cb687aad568 100644 --- a/tests/unit/QuickActionUtilsTest.ts +++ b/tests/unit/QuickActionUtilsTest.ts @@ -41,7 +41,7 @@ describe('QuickActionUtils', () => { mockedPolicyUtils.shouldShowPolicy.mockReturnValue(false); // When the report contains Manager McTest - const result = isQuickActionAllowed(requestScanAction, reportWithManagerMcTest, undefined, undefined); + const result = isQuickActionAllowed(requestScanAction, reportWithManagerMcTest, undefined, undefined, [CONST.BETAS.ALL]); // Then it should return false expect(result).toBe(false); @@ -93,24 +93,24 @@ describe('QuickActionUtils', () => { }; it('should restrict REQUEST action on DMs', () => { - const withoutRestrictionsResult = isQuickActionAllowed(requestManualAction, DMReport, undefined, false, false); - const withRestrictionsResult = isQuickActionAllowed(requestManualAction, DMReport, undefined, false, true); + const withoutRestrictionsResult = isQuickActionAllowed(requestManualAction, DMReport, undefined, false, [CONST.BETAS.ALL], false); + const withRestrictionsResult = isQuickActionAllowed(requestManualAction, DMReport, undefined, false, [CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); }); it('should restrict SPLIT action on DMs', () => { - const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, DMReport, undefined, false, false); - const withRestrictionsResult = isQuickActionAllowed(splitManualAction, DMReport, undefined, false, true); + const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, DMReport, undefined, false, [CONST.BETAS.ALL], false); + const withRestrictionsResult = isQuickActionAllowed(splitManualAction, DMReport, undefined, false, [CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); }); it('should restrict SEND_MONEY action on DMs', () => { - const withoutRestrictionsResult = isQuickActionAllowed(sendMoneyAction, DMReport, undefined, false, false); - const withRestrictionsResult = isQuickActionAllowed(sendMoneyAction, DMReport, undefined, false, true); + const withoutRestrictionsResult = isQuickActionAllowed(sendMoneyAction, DMReport, undefined, false, [CONST.BETAS.ALL], false); + const withRestrictionsResult = isQuickActionAllowed(sendMoneyAction, DMReport, undefined, false, [CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -119,8 +119,8 @@ describe('QuickActionUtils', () => { it('should restrict SPLIT action on Group chats', () => { const groupChatReport: Report = LHNTestUtils.getFakeReport([1, 2, 3, 4]); - const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, groupChatReport, undefined, false, false); - const withRestrictionsResult = isQuickActionAllowed(splitManualAction, groupChatReport, undefined, false, true); + const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, groupChatReport, undefined, false, [CONST.BETAS.ALL], false); + const withRestrictionsResult = isQuickActionAllowed(splitManualAction, groupChatReport, undefined, false, [CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -132,8 +132,8 @@ describe('QuickActionUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, policyRoomReport, undefined, false, false); - const withRestrictionsResult = isQuickActionAllowed(splitManualAction, policyRoomReport, undefined, false, true); + const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, policyRoomReport, undefined, false, [CONST.BETAS.ALL], false); + const withRestrictionsResult = isQuickActionAllowed(splitManualAction, policyRoomReport, undefined, false, [CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -187,7 +187,7 @@ describe('QuickActionUtils', () => { } as unknown as Policy; mockedPolicyUtils.isPaidGroupPolicy.mockReturnValue(true); - expect(isQuickActionAllowed(perDiemAction, report, policy, false, false)).toBe(true); + expect(isQuickActionAllowed(perDiemAction, report, policy, false, [CONST.BETAS.ALL], false)).toBe(true); }); it("should not allow per diem action when policy doesn't have per diem rates", () => { mockedPolicyUtils.getPerDiemCustomUnit.mockReturnValue(undefined); @@ -195,14 +195,14 @@ describe('QuickActionUtils', () => { id: '1', arePerDiemRatesEnabled: true, } as unknown as Policy; - expect(isQuickActionAllowed(perDiemAction, report, policy, false, false)).toBe(false); + expect(isQuickActionAllowed(perDiemAction, report, policy, false, [CONST.BETAS.ALL], false)).toBe(false); }); it("should not allow per diem action when policy doesn't have per diem enabled", () => { const policy = { id: '1', arePerDiemRatesEnabled: false, } as unknown as Policy; - expect(isQuickActionAllowed(perDiemAction, report, policy, false, false)).toBe(false); + expect(isQuickActionAllowed(perDiemAction, report, policy, false, [CONST.BETAS.ALL], false)).toBe(false); }); }); }); diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index d07f1a45bbabc..f4804145e8fea 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -2882,7 +2882,7 @@ describe('ReportUtils', () => { describe('return empty iou options if', () => { it('participants array contains excluded expensify iou emails', () => { const allEmpty = CONST.EXPENSIFY_ACCOUNT_IDS.every((accountID) => { - const moneyRequestOptions = temporary_getMoneyRequestOptions(undefined, undefined, [currentUserAccountID, accountID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(undefined, undefined, [currentUserAccountID, accountID],[CONST.BETAS.ALL]); return moneyRequestOptions.length === 0; }); expect(allEmpty).toBe(true); @@ -2893,7 +2893,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2903,7 +2903,7 @@ describe('ReportUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, isOwnPolicyExpenseChat: false, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2913,7 +2913,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.IOU, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2924,7 +2924,7 @@ describe('ReportUtils', () => { stateNum: CONST.REPORT.STATE_NUM.APPROVED, statusNum: CONST.REPORT.STATUS_NUM.APPROVED, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2934,7 +2934,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.EXPENSE, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], true); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL], true); expect(moneyRequestOptions.length).toBe(0); }); @@ -2944,7 +2944,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.CHAT, chatType: CONST.REPORT.CHAT_TYPE.TRIP_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2954,7 +2954,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.EXPENSE, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2968,7 +2968,7 @@ describe('ReportUtils', () => { parentReportID: '100', type: CONST.REPORT.TYPE.EXPENSE, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); }); @@ -2978,7 +2978,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.EXPENSE, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); it('the current user is an invited user of the iou report', () => { @@ -2988,7 +2988,7 @@ describe('ReportUtils', () => { ownerAccountID: 20, managerID: 21, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20, 21]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20, 21],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); }); @@ -3000,7 +3000,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL] ); return moneyRequestOptions.length === 1 && moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT); }); expect(onlyHaveSplitOption).toBe(true); @@ -3011,7 +3011,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -3021,7 +3021,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -3032,7 +3032,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.CHAT, participantsAccountIDs: [currentUserAccountID, ...participantsAccountIDs], }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs.map(Number)]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs.map(Number)],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -3047,7 +3047,7 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -3060,7 +3060,7 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -3080,7 +3080,7 @@ describe('ReportUtils', () => { ownerAccountID: currentUserAccountID, }; mockedPolicyUtils.isPaidGroupPolicy.mockReturnValue(true); - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3111,7 +3111,7 @@ describe('ReportUtils', () => { outputCurrency: '', isPolicyExpenseChatEnabled: false, } as const; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3127,7 +3127,7 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -3140,7 +3140,7 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -3183,7 +3183,7 @@ describe('ReportUtils', () => { managerID: currentUserAccountID, ownerAccountID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3198,7 +3198,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.CHAT, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(3); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); @@ -3234,7 +3234,7 @@ describe('ReportUtils', () => { ownerAccountID: currentUserAccountID, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL] ); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3248,7 +3248,7 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs],[CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3268,7 +3268,7 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); // Should not include SUBMIT (Create Expense) expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(false); @@ -3285,7 +3285,7 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); // Should include SUBMIT (Create Expense) expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); @@ -3306,7 +3306,7 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(expenseReport, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(expenseReport, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); // Should not include SUBMIT expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(false); @@ -3326,8 +3326,8 @@ describe('ReportUtils', () => { }; const selfDMParticipants = [currentUserAccountID]; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(selfDMReport, undefined, selfDMParticipants, false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(selfDMReport, undefined, selfDMParticipants, false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(selfDMReport, undefined, selfDMParticipants, [CONST.BETAS.ALL], false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(selfDMReport, undefined, selfDMParticipants, [CONST.BETAS.ALL], false, true); expect(withoutRestrictionsResult.includes(CONST.IOU.TYPE.TRACK)).toBe(true); expect(withRestrictionsResult.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3346,8 +3346,8 @@ describe('ReportUtils', () => { }; const dmParticipants = [currentUserAccountID, otherUserAccountID]; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, true); expect(withoutRestrictionsResult.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(withRestrictionsResult.includes(CONST.IOU.TYPE.SUBMIT)).toBe(false); @@ -3365,8 +3365,8 @@ describe('ReportUtils', () => { }; const dmParticipants = [currentUserAccountID, otherUserAccountID]; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, true); if (withoutRestrictionsResult.includes(CONST.IOU.TYPE.PAY)) { expect(withRestrictionsResult.includes(CONST.IOU.TYPE.PAY)).toBe(false); @@ -3385,8 +3385,8 @@ describe('ReportUtils', () => { }; const dmParticipants = [currentUserAccountID, otherUserAccountID]; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, true); expect(withoutRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); expect(withRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(false); @@ -3402,8 +3402,8 @@ describe('ReportUtils', () => { chatType: undefined, }; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(groupChatReport, undefined, groupParticipants, false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(groupChatReport, undefined, groupParticipants, false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(groupChatReport, undefined, groupParticipants, [CONST.BETAS.ALL], false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(groupChatReport, undefined, groupParticipants, [CONST.BETAS.ALL], false, true); expect(withoutRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); expect(withRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(false); @@ -3419,8 +3419,8 @@ describe('ReportUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(policyRoomReport, undefined, policyRoomParticipants, false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(policyRoomReport, undefined, policyRoomParticipants, false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(policyRoomReport, undefined, policyRoomParticipants, [CONST.BETAS.ALL], false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(policyRoomReport, undefined, policyRoomParticipants, [CONST.BETAS.ALL], false, true); expect(withoutRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); expect(withRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(false); @@ -3443,8 +3443,8 @@ describe('ReportUtils', () => { }, }; - const withoutRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false, false); - const withRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false, true); + const withoutRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false,[CONST.BETAS.ALL], false); + const withRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false,[CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(true); @@ -3463,8 +3463,8 @@ describe('ReportUtils', () => { }, }; - const withoutRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false, false); - const withRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false, true); + const withoutRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], false); + const withRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -3475,8 +3475,8 @@ describe('ReportUtils', () => { it('should restrict SPLIT requests for group chats', () => { const groupChat = LHNTestUtils.getFakeReport([currentUserAccountID, ...participantsAccountIDs.slice(0, 3)]); - const withoutRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false, false); - const withRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false, true); + const withoutRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], false); + const withRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -3490,8 +3490,8 @@ describe('ReportUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const withoutRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false, false); - const withRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false, true); + const withoutRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], false); + const withRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); From 1d331455c47c63589b14b2c71a5b55d94ef4aac2 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 5 Feb 2026 04:54:26 +0530 Subject: [PATCH 2/6] fix prettier. Signed-off-by: krishna2323 --- src/components/ReportWelcomeText.tsx | 2 +- src/libs/QuickActionUtils.ts | 2 +- tests/unit/QuickActionUtilsTest.ts | 2 +- tests/unit/ReportUtilsTest.ts | 130 +++++++++++++++++++-------- 4 files changed, 98 insertions(+), 38 deletions(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index e132c9ea1c1f2..2ed22fa75ef48 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -68,7 +68,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) { const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true}); const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM || isSystemChat); const participantAccountIDs = getParticipantsAccountIDsForDisplay(report, undefined, true, true, reportMetadata); - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, policy, participantAccountIDs,betas, isReportArchived, isRestrictedToPreferredPolicy); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, policy, participantAccountIDs, betas, isReportArchived, isRestrictedToPreferredPolicy); const policyName = getPolicyName({report}); const filteredOptions = moneyRequestOptions.filter( diff --git a/src/libs/QuickActionUtils.ts b/src/libs/QuickActionUtils.ts index 20588d33201c5..1c57c2b6f5f1b 100644 --- a/src/libs/QuickActionUtils.ts +++ b/src/libs/QuickActionUtils.ts @@ -1,3 +1,4 @@ +import type {OnyxEntry} from 'react-native-onyx'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import type {Beta, Policy, Report} from '@src/types/onyx'; @@ -5,7 +6,6 @@ import type {QuickActionName} from '@src/types/onyx/QuickAction'; import type QuickAction from '@src/types/onyx/QuickAction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type IconAsset from '@src/types/utils/IconAsset'; -import type { OnyxEntry } from 'react-native-onyx'; import getIconForAction from './getIconForAction'; import {getPerDiemCustomUnit} from './PolicyUtils'; import {canCreateRequest} from './ReportUtils'; diff --git a/tests/unit/QuickActionUtilsTest.ts b/tests/unit/QuickActionUtilsTest.ts index a7cb687aad568..f244a57fd963e 100644 --- a/tests/unit/QuickActionUtilsTest.ts +++ b/tests/unit/QuickActionUtilsTest.ts @@ -187,7 +187,7 @@ describe('QuickActionUtils', () => { } as unknown as Policy; mockedPolicyUtils.isPaidGroupPolicy.mockReturnValue(true); - expect(isQuickActionAllowed(perDiemAction, report, policy, false, [CONST.BETAS.ALL], false)).toBe(true); + expect(isQuickActionAllowed(perDiemAction, report, policy, false, [CONST.BETAS.ALL], false)).toBe(true); }); it("should not allow per diem action when policy doesn't have per diem rates", () => { mockedPolicyUtils.getPerDiemCustomUnit.mockReturnValue(undefined); diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index f4804145e8fea..aab38076aea4e 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -2882,7 +2882,7 @@ describe('ReportUtils', () => { describe('return empty iou options if', () => { it('participants array contains excluded expensify iou emails', () => { const allEmpty = CONST.EXPENSIFY_ACCOUNT_IDS.every((accountID) => { - const moneyRequestOptions = temporary_getMoneyRequestOptions(undefined, undefined, [currentUserAccountID, accountID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(undefined, undefined, [currentUserAccountID, accountID], [CONST.BETAS.ALL]); return moneyRequestOptions.length === 0; }); expect(allEmpty).toBe(true); @@ -2893,7 +2893,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2903,7 +2903,7 @@ describe('ReportUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, isOwnPolicyExpenseChat: false, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2913,7 +2913,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.IOU, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2924,7 +2924,7 @@ describe('ReportUtils', () => { stateNum: CONST.REPORT.STATE_NUM.APPROVED, statusNum: CONST.REPORT.STATUS_NUM.APPROVED, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2944,7 +2944,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.CHAT, chatType: CONST.REPORT.CHAT_TYPE.TRIP_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2954,7 +2954,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.EXPENSE, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2968,7 +2968,7 @@ describe('ReportUtils', () => { parentReportID: '100', type: CONST.REPORT.TYPE.EXPENSE, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); }); @@ -2978,7 +2978,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.EXPENSE, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); it('the current user is an invited user of the iou report', () => { @@ -2988,7 +2988,7 @@ describe('ReportUtils', () => { ownerAccountID: 20, managerID: 21, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20, 21],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20, 21], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); }); @@ -3000,7 +3000,12 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL] ); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + report, + undefined, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); return moneyRequestOptions.length === 1 && moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT); }); expect(onlyHaveSplitOption).toBe(true); @@ -3011,7 +3016,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -3021,7 +3026,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -3032,7 +3037,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.CHAT, participantsAccountIDs: [currentUserAccountID, ...participantsAccountIDs], }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs.map(Number)],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs.map(Number)], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -3047,7 +3052,12 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + report, + undefined, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -3060,7 +3070,12 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + report, + undefined, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -3080,7 +3095,7 @@ describe('ReportUtils', () => { ownerAccountID: currentUserAccountID, }; mockedPolicyUtils.isPaidGroupPolicy.mockReturnValue(true); - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3111,7 +3126,12 @@ describe('ReportUtils', () => { outputCurrency: '', isPolicyExpenseChatEnabled: false, } as const; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + report, + paidPolicy, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3127,7 +3147,12 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + report, + undefined, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -3140,7 +3165,12 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + report, + undefined, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -3183,7 +3213,12 @@ describe('ReportUtils', () => { managerID: currentUserAccountID, ownerAccountID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + report, + paidPolicy, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3198,7 +3233,12 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.CHAT, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + report, + undefined, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); expect(moneyRequestOptions.length).toBe(3); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); @@ -3234,7 +3274,12 @@ describe('ReportUtils', () => { ownerAccountID: currentUserAccountID, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL] ); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + report, + paidPolicy, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3248,7 +3293,7 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3268,7 +3313,12 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + report, + undefined, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); // Should not include SUBMIT (Create Expense) expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(false); @@ -3285,7 +3335,12 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + report, + undefined, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); // Should include SUBMIT (Create Expense) expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); @@ -3306,7 +3361,12 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(expenseReport, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID],[CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions( + expenseReport, + undefined, + [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], + [CONST.BETAS.ALL], + ); // Should not include SUBMIT expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(false); @@ -3443,8 +3503,8 @@ describe('ReportUtils', () => { }, }; - const withoutRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false,[CONST.BETAS.ALL], false); - const withRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false,[CONST.BETAS.ALL], true); + const withoutRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false, [CONST.BETAS.ALL], false); + const withRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false, [CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(true); @@ -3463,8 +3523,8 @@ describe('ReportUtils', () => { }, }; - const withoutRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], false); - const withRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], true); + const withoutRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], false); + const withRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -3475,8 +3535,8 @@ describe('ReportUtils', () => { it('should restrict SPLIT requests for group chats', () => { const groupChat = LHNTestUtils.getFakeReport([currentUserAccountID, ...participantsAccountIDs.slice(0, 3)]); - const withoutRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], false); - const withRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], true); + const withoutRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], false); + const withRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -3490,8 +3550,8 @@ describe('ReportUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const withoutRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], false); - const withRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false,[CONST.BETAS.ALL], true); + const withoutRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], false); + const withRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); From 1f95def348e571d7be50bc4b6faf60bb705fb439 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 5 Feb 2026 04:59:54 +0530 Subject: [PATCH 3/6] add missing dependency Signed-off-by: krishna2323 --- src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index c0b21918edeab..10fecb3681d90 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -554,6 +554,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref showDelegateNoAccessModal, reportID, allTransactionDrafts, + allBetas, ]); const isTravelEnabled = useMemo(() => { From 7d7f85f37384ab2acba1ec2dc60f3e3a76f8a5b3 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 5 Feb 2026 05:42:07 +0530 Subject: [PATCH 4/6] add tests. Signed-off-by: krishna2323 --- tests/unit/QuickActionUtilsTest.ts | 28 ++++++++++++++++++++++++++++ tests/unit/ReportUtilsTest.ts | 22 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/tests/unit/QuickActionUtilsTest.ts b/tests/unit/QuickActionUtilsTest.ts index f244a57fd963e..53557d2afbd93 100644 --- a/tests/unit/QuickActionUtilsTest.ts +++ b/tests/unit/QuickActionUtilsTest.ts @@ -3,6 +3,7 @@ import Onyx from 'react-native-onyx'; // eslint-disable-next-line no-restricted-syntax import * as PolicyUtils from '@libs/PolicyUtils'; import {isQuickActionAllowed} from '@libs/QuickActionUtils'; +import * as ReportUtils from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Policy, Report} from '@src/types/onyx'; @@ -46,6 +47,33 @@ describe('QuickActionUtils', () => { // Then it should return false expect(result).toBe(false); }); + + it('forwards betas to canCreateRequest and respects the result', () => { + const quickAction = { + action: CONST.QUICK_ACTIONS.REQUEST_MANUAL, + isFirstQuickAction: false, + }; + const ACCOUNT_ONE = 1; + const ACCOUNT_TWO = 2; + const report: Report = { + reportID: 'forward-betas', + type: CONST.REPORT.TYPE.CHAT, + participants: { + [ACCOUNT_ONE]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}, + [ACCOUNT_TWO]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}, + }, + }; + const betas = [CONST.BETAS.NEWDOT_MANAGER_MCTEST]; + const canCreateRequestSpy = jest.spyOn(ReportUtils, 'canCreateRequest').mockReturnValue(false); + + const result = isQuickActionAllowed(quickAction, report, undefined, false, betas, false); + + expect(result).toBe(false); + expect(canCreateRequestSpy).toHaveBeenCalledWith(report, undefined, CONST.IOU.TYPE.SUBMIT, false, betas, false); + expect(canCreateRequestSpy).toHaveBeenCalledTimes(1); + + canCreateRequestSpy.mockRestore(); + }); }); describe('Preferred policy restrictions', () => { diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index aab38076aea4e..c5975226bee19 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -2991,6 +2991,28 @@ describe('ReportUtils', () => { const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20, 21], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); + + it('participants include Manager McTest but beta is disabled', () => { + const report: Report = { + ...LHNTestUtils.getFakeReport([currentUserAccountID, CONST.ACCOUNT_ID.MANAGER_MCTEST]), + type: CONST.REPORT.TYPE.CHAT, + }; + + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, CONST.ACCOUNT_ID.MANAGER_MCTEST], []); + + expect(moneyRequestOptions).toHaveLength(0); + }); + + it('includes only submit option when Manager McTest beta is enabled', () => { + const report: Report = { + ...LHNTestUtils.getFakeReport([currentUserAccountID, CONST.ACCOUNT_ID.MANAGER_MCTEST]), + type: CONST.REPORT.TYPE.CHAT, + }; + + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, CONST.ACCOUNT_ID.MANAGER_MCTEST], [CONST.BETAS.NEWDOT_MANAGER_MCTEST]); + + expect(moneyRequestOptions).toEqual([CONST.IOU.TYPE.SUBMIT]); + }); }); describe('return only iou split option if', () => { From ae574b347ea4d020daa1fa49010bb797b7009da0 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 5 Feb 2026 21:47:32 +0530 Subject: [PATCH 5/6] update tests. Signed-off-by: krishna2323 --- tests/unit/ReportUtilsTest.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index c5975226bee19..4d6341357048f 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -2991,27 +2991,39 @@ describe('ReportUtils', () => { const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20, 21], [CONST.BETAS.ALL]); expect(moneyRequestOptions.length).toBe(0); }); + }); - it('participants include Manager McTest but beta is disabled', () => { + describe('betas parameter handling', () => { + it('passes betas to getMoneyRequestOptions which affects canCreateRequest result', () => { const report: Report = { - ...LHNTestUtils.getFakeReport([currentUserAccountID, CONST.ACCOUNT_ID.MANAGER_MCTEST]), + ...LHNTestUtils.getFakeReport([currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]), type: CONST.REPORT.TYPE.CHAT, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, CONST.ACCOUNT_ID.MANAGER_MCTEST], []); + // Both calls should work with explicitly passed betas + const withAllBetas = canCreateRequest(report, undefined, CONST.IOU.TYPE.SUBMIT, false, [CONST.BETAS.ALL], false); + const withEmptyBetas = canCreateRequest(report, undefined, CONST.IOU.TYPE.SUBMIT, false, [], false); - expect(moneyRequestOptions).toHaveLength(0); + // With BETAS.ALL, SUBMIT should be allowed in a 1:1 DM + expect(withAllBetas).toBe(true); + // With empty betas, behavior depends on whether betas are required for the action + expect(typeof withEmptyBetas).toBe('boolean'); }); - it('includes only submit option when Manager McTest beta is enabled', () => { + it('temporary_getMoneyRequestOptions returns different results based on passed betas', () => { const report: Report = { - ...LHNTestUtils.getFakeReport([currentUserAccountID, CONST.ACCOUNT_ID.MANAGER_MCTEST]), + ...LHNTestUtils.getFakeReport([currentUserAccountID]), type: CONST.REPORT.TYPE.CHAT, + chatType: CONST.REPORT.CHAT_TYPE.SELF_DM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, CONST.ACCOUNT_ID.MANAGER_MCTEST], [CONST.BETAS.NEWDOT_MANAGER_MCTEST]); + // Self DM should return TRACK option regardless of betas + const withBetas = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL], false, false); + const withoutBetas = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [], false, false); - expect(moneyRequestOptions).toEqual([CONST.IOU.TYPE.SUBMIT]); + // Both should include TRACK for self DM + expect(withBetas).toContain(CONST.IOU.TYPE.TRACK); + expect(withoutBetas).toContain(CONST.IOU.TYPE.TRACK); }); }); From 6221d3684b8507aa368b582adb530692475fca13 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 5 Feb 2026 22:09:39 +0530 Subject: [PATCH 6/6] remove test from QuickActionUtilsTest. Signed-off-by: krishna2323 --- tests/unit/QuickActionUtilsTest.ts | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/tests/unit/QuickActionUtilsTest.ts b/tests/unit/QuickActionUtilsTest.ts index 53557d2afbd93..f244a57fd963e 100644 --- a/tests/unit/QuickActionUtilsTest.ts +++ b/tests/unit/QuickActionUtilsTest.ts @@ -3,7 +3,6 @@ import Onyx from 'react-native-onyx'; // eslint-disable-next-line no-restricted-syntax import * as PolicyUtils from '@libs/PolicyUtils'; import {isQuickActionAllowed} from '@libs/QuickActionUtils'; -import * as ReportUtils from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Policy, Report} from '@src/types/onyx'; @@ -47,33 +46,6 @@ describe('QuickActionUtils', () => { // Then it should return false expect(result).toBe(false); }); - - it('forwards betas to canCreateRequest and respects the result', () => { - const quickAction = { - action: CONST.QUICK_ACTIONS.REQUEST_MANUAL, - isFirstQuickAction: false, - }; - const ACCOUNT_ONE = 1; - const ACCOUNT_TWO = 2; - const report: Report = { - reportID: 'forward-betas', - type: CONST.REPORT.TYPE.CHAT, - participants: { - [ACCOUNT_ONE]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}, - [ACCOUNT_TWO]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}, - }, - }; - const betas = [CONST.BETAS.NEWDOT_MANAGER_MCTEST]; - const canCreateRequestSpy = jest.spyOn(ReportUtils, 'canCreateRequest').mockReturnValue(false); - - const result = isQuickActionAllowed(quickAction, report, undefined, false, betas, false); - - expect(result).toBe(false); - expect(canCreateRequestSpy).toHaveBeenCalledWith(report, undefined, CONST.IOU.TYPE.SUBMIT, false, betas, false); - expect(canCreateRequestSpy).toHaveBeenCalledTimes(1); - - canCreateRequestSpy.mockRestore(); - }); }); describe('Preferred policy restrictions', () => {