From 3ab887735e68ca7238ce5ae5e36a962c988191a5 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:06:46 +0530 Subject: [PATCH 1/8] Take violations out of beta --- .../LHNOptionsList/LHNOptionsList.tsx | 3 -- .../LHNOptionsList/OptionRowLHNData.tsx | 4 +- src/components/LHNOptionsList/types.ts | 3 -- .../MoneyRequestConfirmationListFooter.tsx | 5 +- .../MoneyRequestPreviewContent.tsx | 6 +-- .../ReportActionItem/MoneyRequestView.tsx | 8 ++-- .../ReportActionItem/ReportPreview.tsx | 3 +- src/hooks/__mocks__/usePermissions.ts | 7 --- src/libs/OptionsListUtils.ts | 3 -- src/libs/Permissions.ts | 5 -- src/libs/SidebarUtils.ts | 1 - src/libs/__mocks__/Permissions.ts | 1 - src/libs/actions/IOU.ts | 48 ++++++++----------- src/pages/ReportDetailsPage.tsx | 2 +- 14 files changed, 31 insertions(+), 68 deletions(-) delete mode 100644 src/hooks/__mocks__/usePermissions.ts diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index 2cc931303a30..87333b091905 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -42,7 +42,6 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio const theme = useTheme(); const styles = useThemeStyles(); - const {canUseViolations} = usePermissions(); const {translate, preferredLocale} = useLocalize(); const {shouldUseNarrowLayout} = useResponsiveLayout(); const shouldShowEmptyLHN = shouldUseNarrowLayout && data.length === 0; @@ -152,7 +151,6 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio preferredLocale={preferredLocale} hasDraftComment={hasDraftComment} transactionViolations={transactionViolations} - canUseViolations={canUseViolations} onLayout={onLayoutItem} /> ); @@ -169,7 +167,6 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio shouldDisableFocusOptions, transactions, transactionViolations, - canUseViolations, onLayoutItem, ], ); diff --git a/src/components/LHNOptionsList/OptionRowLHNData.tsx b/src/components/LHNOptionsList/OptionRowLHNData.tsx index bb5fdb580aa7..fdc6208310cd 100644 --- a/src/components/LHNOptionsList/OptionRowLHNData.tsx +++ b/src/components/LHNOptionsList/OptionRowLHNData.tsx @@ -26,7 +26,6 @@ function OptionRowLHNData({ transaction, lastReportActionTransaction, transactionViolations, - canUseViolations, ...propsToForward }: OptionRowLHNDataProps) { const reportID = propsToForward.reportID; @@ -35,7 +34,7 @@ function OptionRowLHNData({ const optionItemRef = useRef(); - const shouldDisplayViolations = canUseViolations && ReportUtils.shouldDisplayTransactionThreadViolations(fullReport, transactionViolations, parentReportAction); + const shouldDisplayViolations = ReportUtils.shouldDisplayTransactionThreadViolations(fullReport, transactionViolations, parentReportAction); const optionItem = useMemo(() => { // Note: ideally we'd have this as a dependent selector in onyx! @@ -69,7 +68,6 @@ function OptionRowLHNData({ parentReportAction, transaction, transactionViolations, - canUseViolations, receiptTransactions, ]); diff --git a/src/components/LHNOptionsList/types.ts b/src/components/LHNOptionsList/types.ts index 2a4b09e8fcec..5cd33064af19 100644 --- a/src/components/LHNOptionsList/types.ts +++ b/src/components/LHNOptionsList/types.ts @@ -74,9 +74,6 @@ type OptionRowLHNDataProps = { /** List of transaction violation */ transactionViolations: OnyxCollection; - /** Whether the user can use violations */ - canUseViolations: boolean | undefined; - /** Toggle between compact and default view */ viewMode?: OptionMode; diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx index 48190fb3c759..eea3d2ec0ca3 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -218,7 +218,6 @@ function MoneyRequestConfirmationListFooter({ const theme = useTheme(); const {translate, toLocaleDigit} = useLocalize(); const {isOffline} = useNetwork(); - const {canUseViolations} = usePermissions(iouType); const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); // A flag and a toggler for showing the rest of the form fields @@ -437,7 +436,7 @@ function MoneyRequestConfirmationListFooter({ titleStyle={styles.flex1} disabled={didConfirm} interactive={!isReadOnly} - rightLabel={isCategoryRequired && canUseViolations ? translate('common.required') : ''} + rightLabel={isCategoryRequired ? translate('common.required') : ''} /> ), shouldShow: shouldShowCategories, @@ -462,7 +461,7 @@ function MoneyRequestConfirmationListFooter({ style={[styles.moneyRequestMenuItem]} disabled={didConfirm} interactive={!isReadOnly} - rightLabel={isTagRequired && canUseViolations ? translate('common.required') : ''} + rightLabel={isTagRequired ? translate('common.required') : ''} /> ), shouldShow, diff --git a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx index 896432708aff..19657df4338b 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx @@ -84,7 +84,6 @@ function MoneyRequestPreviewContent({ const managerID = iouReport?.managerID ?? -1; const ownerAccountID = iouReport?.ownerAccountID ?? -1; const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport); - const {canUseViolations} = usePermissions(); const participantAccountIDs = ReportActionsUtils.isMoneyRequestAction(action) && isBillSplit ? ReportActionsUtils.getOriginalMessage(action)?.participantAccountIDs ?? [] : [managerID, ownerAccountID]; @@ -112,10 +111,9 @@ function MoneyRequestPreviewContent({ const isSettlementOrApprovalPartial = !!iouReport?.pendingFields?.partial; const isPartialHold = isSettlementOrApprovalPartial && isOnHold; const hasViolations = TransactionUtils.hasViolation(transaction?.transactionID ?? '-1', transactionViolations); - const hasNoticeTypeViolations = !!( + const hasNoticeTypeViolations = ( TransactionUtils.hasNoticeTypeViolation(transaction?.transactionID ?? '-1', transactionViolations) && - ReportUtils.isPaidGroupPolicy(iouReport) && - canUseViolations + ReportUtils.isPaidGroupPolicy(iouReport) ); const hasFieldErrors = TransactionUtils.hasMissingSmartscanFields(transaction); const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction); diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index a0d73a1b2844..73bdae30cffc 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -118,7 +118,7 @@ function MoneyRequestView({ const parentReportAction = parentReportActions?.[report.parentReportActionID ?? '-1']; const isTrackExpense = ReportUtils.isTrackExpenseReport(report); - const {canUseViolations, canUseP2PDistanceRequests} = usePermissions(isTrackExpense ? CONST.IOU.TYPE.TRACK : undefined); + const {canUseP2PDistanceRequests} = usePermissions(isTrackExpense ? CONST.IOU.TYPE.TRACK : undefined); const moneyRequestReport = parentReport; const { created: transactionDate, @@ -192,8 +192,8 @@ function MoneyRequestView({ const {getViolationsForField} = useViolations(transactionViolations ?? []); const hasViolations = useCallback( (field: ViolationField, data?: OnyxTypes.TransactionViolation['data'], policyHasDependentTags = false, tagValue?: string): boolean => - !!canUseViolations && getViolationsForField(field, data, policyHasDependentTags, tagValue).length > 0, - [canUseViolations, getViolationsForField], + getViolationsForField(field, data, policyHasDependentTags, tagValue).length > 0, + [getViolationsForField], ); let amountDescription = `${translate('iou.amount')}`; @@ -346,7 +346,7 @@ function MoneyRequestView({ ]; const receiptViolations = transactionViolations?.filter((violation) => receiptViolationNames.includes(violation.name)).map((violation) => ViolationsUtils.getViolationTranslation(violation, translate)) ?? []; - const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report); + const shouldShowNotesViolations = !isReceiptBeingScanned && ReportUtils.isPaidGroupPolicy(report); const shouldShowReceiptHeader = isReceiptAllowed && (shouldShowReceiptEmptyState || hasReceipt); const errors = { diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index 4a145d4e79e9..00ef94d3d289 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -110,7 +110,6 @@ function ReportPreview({ const theme = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); - const {canUseViolations} = usePermissions(); const {isOffline} = useNetwork(); const {hasMissingSmartscanFields, areAllRequestsBeingSmartScanned, hasOnlyTransactionsWithPendingRoutes, hasNonReimbursableTransactions} = useMemo( @@ -153,7 +152,7 @@ function ReportPreview({ const hasErrors = hasMissingSmartscanFields || // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - (canUseViolations && (ReportUtils.hasViolations(iouReportID, transactionViolations) || ReportUtils.hasWarningTypeViolations(iouReportID, transactionViolations))) || + (ReportUtils.hasViolations(iouReportID, transactionViolations) || ReportUtils.hasWarningTypeViolations(iouReportID, transactionViolations)) || ReportUtils.hasActionsWithErrors(iouReportID); const lastThreeTransactionsWithReceipts = transactionsWithReceipts.slice(-3); const lastThreeReceipts = lastThreeTransactionsWithReceipts.map((transaction) => ({...ReceiptUtils.getThumbnailAndImageURIs(transaction), transaction})); diff --git a/src/hooks/__mocks__/usePermissions.ts b/src/hooks/__mocks__/usePermissions.ts deleted file mode 100644 index a12b1f52d8ab..000000000000 --- a/src/hooks/__mocks__/usePermissions.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @returns A mock of the usePermissions hook. - */ -const usePermissions = () => ({ - canUseViolations: true, -}); -export default usePermissions; diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 97c9a0965f1d..5754a8d17040 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1752,9 +1752,6 @@ function getUserToInviteOption({ * Check whether report has violations */ function shouldShowViolations(report: Report, betas: OnyxEntry, transactionViolations: OnyxCollection) { - if (!Permissions.canUseViolations(betas)) { - return false; - } const {parentReportID, parentReportActionID} = report ?? {}; const canGetParentReport = parentReportID && parentReportActionID && allReportActions; if (!canGetParentReport) { diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index faea5965fee4..466d5f2bd0f0 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -19,10 +19,6 @@ function canUseReportFields(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.REPORT_FIELDS) || canUseAllBetas(betas); } -function canUseViolations(betas: OnyxEntry): boolean { - return !!betas?.includes(CONST.BETAS.VIOLATIONS) || canUseAllBetas(betas); -} - function canUseDupeDetection(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.DUPE_DETECTION) || canUseAllBetas(betas); } @@ -71,7 +67,6 @@ export default { canUseChronos, canUseDefaultRooms, canUseLinkPreviews, - canUseViolations, canUseDupeDetection, canUseReportFields, canUseP2PDistanceRequests, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 3151f522d800..c2842803baba 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -305,7 +305,6 @@ function getOptionData({ const oneTransactionThreadReport = ReportUtils.getReport(oneTransactionThreadReportID); if ( - Permissions.canUseViolations(allBetas) && ReportUtils.shouldDisplayTransactionThreadViolations( oneTransactionThreadReport, transactionViolations, diff --git a/src/libs/__mocks__/Permissions.ts b/src/libs/__mocks__/Permissions.ts index 702aec6a7bd4..40fc9ea66317 100644 --- a/src/libs/__mocks__/Permissions.ts +++ b/src/libs/__mocks__/Permissions.ts @@ -12,5 +12,4 @@ import type Beta from '@src/types/onyx/Beta'; export default { ...jest.requireActual('../Permissions'), canUseDefaultRooms: (betas: Beta[]) => betas.includes(CONST.BETAS.DEFAULT_ROOMS), - canUseViolations: (betas: Beta[]) => betas.includes(CONST.BETAS.VIOLATIONS), }; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 65f958cad8e8..7f37c6c6b6e1 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1639,13 +1639,11 @@ function getDeleteTrackExpenseInformation( }); } - if (Permissions.canUseViolations(betas)) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.SET, - key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, - value: null, - }); - } + optimisticData.push({ + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, + value: null, + }); if (shouldDeleteTransactionThread) { optimisticData.push( @@ -1702,13 +1700,11 @@ function getDeleteTrackExpenseInformation( }); } - if (Permissions.canUseViolations(betas)) { - failureData.push({ - onyxMethod: Onyx.METHOD.SET, - key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, - value: transactionViolations ?? null, - }); - } + failureData.push({ + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, + value: transactionViolations ?? null, + }); if (shouldDeleteTransactionThread) { failureData.push({ @@ -5419,13 +5415,11 @@ function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repor }, ]; - if (Permissions.canUseViolations(betas)) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.SET, - key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, - value: null, - }); - } + optimisticData.push({ + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, + value: null, + }); if (shouldDeleteTransactionThread) { optimisticData.push( @@ -5530,13 +5524,11 @@ function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repor }, ]; - if (Permissions.canUseViolations(betas)) { - failureData.push({ - onyxMethod: Onyx.METHOD.SET, - key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, - value: transactionViolations ?? null, - }); - } + failureData.push({ + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, + value: transactionViolations ?? null, + }); if (shouldDeleteTransactionThread) { failureData.push({ diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index ea9746aaeb77..a6438fcea7a0 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -108,7 +108,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const isUserCreatedPolicyRoom = useMemo(() => ReportUtils.isUserCreatedPolicyRoom(report), [report]); const isDefaultRoom = useMemo(() => ReportUtils.isDefaultRoom(report), [report]); const isChatThread = useMemo(() => ReportUtils.isChatThread(report), [report]); - const isArchivedRoom = useMemo(() => ReportUtils.isArchivedRoom(report), [report]); + const isArchivedRoom = useMemo(() => ReportUtils.isArchivedRoom(report, reportNameValuePairs), [report]); const isMoneyRequestReport = useMemo(() => ReportUtils.isMoneyRequestReport(report), [report]); const isMoneyRequest = useMemo(() => ReportUtils.isMoneyRequest(report), [report]); const isInvoiceReport = useMemo(() => ReportUtils.isInvoiceReport(report), [report]); From 99fb15c1236137816ed68ddeedd75f52a0af3821 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Wed, 24 Jul 2024 00:18:15 +0530 Subject: [PATCH 2/8] Update --- src/hooks/__mocks__/usePermissions.ts | 7 +++++++ src/libs/actions/IOU.ts | 13 +++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 src/hooks/__mocks__/usePermissions.ts diff --git a/src/hooks/__mocks__/usePermissions.ts b/src/hooks/__mocks__/usePermissions.ts new file mode 100644 index 000000000000..a12b1f52d8ab --- /dev/null +++ b/src/hooks/__mocks__/usePermissions.ts @@ -0,0 +1,7 @@ +/** + * @returns A mock of the usePermissions hook. + */ +const usePermissions = () => ({ + canUseViolations: true, +}); +export default usePermissions; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index acfd445b3986..b2e953fea5f7 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5500,14 +5500,11 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo }); } - // added the operation to delete associated transaction violations - if (Permissions.canUseViolations(betas)) { - onyxUpdates.push({ - onyxMethod: Onyx.METHOD.SET, - key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, - value: null, - }); - } + onyxUpdates.push({ + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, + value: null, + }); // added the operation to delete transaction thread if (shouldDeleteTransactionThread) { From 4ebaf2a61b01cd9465e97d0dbd006bd13886ec9c Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Wed, 24 Jul 2024 00:30:11 +0530 Subject: [PATCH 3/8] Update --- src/CONST.ts | 1 - src/hooks/__mocks__/usePermissions.ts | 7 ------- src/libs/Permissions.ts | 4 ---- tests/perf-test/ReportScreen.perf-test.tsx | 1 - tests/perf-test/SidebarLinks.perf-test.tsx | 1 - tests/unit/SidebarFilterTest.ts | 1 - tests/unit/SidebarOrderTest.ts | 1 - tests/unit/SidebarTest.ts | 1 - 8 files changed, 17 deletions(-) delete mode 100644 src/hooks/__mocks__/usePermissions.ts diff --git a/src/CONST.ts b/src/CONST.ts index 481c87daace4..9da150512889 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -363,7 +363,6 @@ const CONST = { ALL: 'all', CHRONOS_IN_CASH: 'chronosInCash', DEFAULT_ROOMS: 'defaultRooms', - VIOLATIONS: 'violations', DUPE_DETECTION: 'dupeDetection', P2P_DISTANCE_REQUESTS: 'p2pDistanceRequests', WORKFLOWS_DELAYED_SUBMISSION: 'workflowsDelayedSubmission', diff --git a/src/hooks/__mocks__/usePermissions.ts b/src/hooks/__mocks__/usePermissions.ts deleted file mode 100644 index a12b1f52d8ab..000000000000 --- a/src/hooks/__mocks__/usePermissions.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @returns A mock of the usePermissions hook. - */ -const usePermissions = () => ({ - canUseViolations: true, -}); -export default usePermissions; diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 6554ede2caf7..057e05c284e6 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -15,10 +15,6 @@ function canUseDefaultRooms(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.DEFAULT_ROOMS) || canUseAllBetas(betas); } -function canUseReportFields(betas: OnyxEntry): boolean { - return !!betas?.includes(CONST.BETAS.REPORT_FIELDS) || canUseAllBetas(betas); -} - function canUseDupeDetection(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.DUPE_DETECTION) || canUseAllBetas(betas); } diff --git a/tests/perf-test/ReportScreen.perf-test.tsx b/tests/perf-test/ReportScreen.perf-test.tsx index 3621566fe56c..69469a7cdb45 100644 --- a/tests/perf-test/ReportScreen.perf-test.tsx +++ b/tests/perf-test/ReportScreen.perf-test.tsx @@ -105,7 +105,6 @@ jest.mock('@src/libs/Permissions', () => ({ canUseLinkPreviews: jest.fn(() => true), canUseDefaultRooms: jest.fn(() => true), })); -jest.mock('@src/hooks/usePermissions.ts'); jest.mock('@src/libs/Navigation/Navigation', () => ({ isNavigationReady: jest.fn(() => Promise.resolve()), diff --git a/tests/perf-test/SidebarLinks.perf-test.tsx b/tests/perf-test/SidebarLinks.perf-test.tsx index 0bd2e83f4e72..0b851a56f2ad 100644 --- a/tests/perf-test/SidebarLinks.perf-test.tsx +++ b/tests/perf-test/SidebarLinks.perf-test.tsx @@ -10,7 +10,6 @@ import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates'; jest.mock('@libs/Permissions'); -jest.mock('@hooks/usePermissions.ts'); jest.mock('@src/hooks/useActiveWorkspaceFromNavigationState'); jest.mock('../../src/libs/Navigation/Navigation', () => ({ navigate: jest.fn(), diff --git a/tests/unit/SidebarFilterTest.ts b/tests/unit/SidebarFilterTest.ts index 1c70993c8fad..5505ffdd0971 100644 --- a/tests/unit/SidebarFilterTest.ts +++ b/tests/unit/SidebarFilterTest.ts @@ -12,7 +12,6 @@ import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatch // Be sure to include the mocked permissions library, as some components that are rendered // during the test depend on its methods. jest.mock('@libs/Permissions'); -jest.mock('@hooks/usePermissions.ts'); const ONYXKEYS = { PERSONAL_DETAILS_LIST: 'personalDetailsList', diff --git a/tests/unit/SidebarOrderTest.ts b/tests/unit/SidebarOrderTest.ts index c8b885f98205..96a5e0271e7b 100644 --- a/tests/unit/SidebarOrderTest.ts +++ b/tests/unit/SidebarOrderTest.ts @@ -12,7 +12,6 @@ import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatch // Be sure to include the mocked Permissions and Expensicons libraries as well as the usePermissions hook or else the beta tests won't work jest.mock('@libs/Permissions'); -jest.mock('@hooks/usePermissions.ts'); jest.mock('@components/Icon/Expensicons'); jest.mock('@src/hooks/useActiveWorkspaceFromNavigationState'); diff --git a/tests/unit/SidebarTest.ts b/tests/unit/SidebarTest.ts index f9b258228937..5df2dcd964ca 100644 --- a/tests/unit/SidebarTest.ts +++ b/tests/unit/SidebarTest.ts @@ -12,7 +12,6 @@ import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatch // Be sure to include the mocked Permissions and Expensicons libraries as well as the usePermissions hook or else the beta tests won't work jest.mock('@src/libs/Permissions'); -jest.mock('@src/hooks/usePermissions.ts'); jest.mock('@src/hooks/useActiveWorkspaceFromNavigationState'); jest.mock('@src/components/Icon/Expensicons'); From bc40fcc5f3482e64ffe6648e1d31117cca155865 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Wed, 24 Jul 2024 01:22:36 +0530 Subject: [PATCH 4/8] Lint fixes --- src/components/LHNOptionsList/LHNOptionsList.tsx | 1 - src/components/LHNOptionsList/OptionRowLHNData.tsx | 13 +------------ .../MoneyRequestConfirmationListFooter.tsx | 1 - .../MoneyRequestPreviewContent.tsx | 6 +----- .../ReportActionItem/MoneyRequestView.tsx | 3 +-- src/components/ReportActionItem/ReportPreview.tsx | 4 ++-- src/libs/SidebarUtils.ts | 7 ------- src/libs/actions/IOU.ts | 7 ------- 8 files changed, 5 insertions(+), 37 deletions(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index 87333b091905..c7b3195aa1eb 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -12,7 +12,6 @@ import LottieAnimations from '@components/LottieAnimations'; import {ScrollOffsetContext} from '@components/ScrollOffsetContextProvider'; import TextBlock from '@components/TextBlock'; import useLocalize from '@hooks/useLocalize'; -import usePermissions from '@hooks/usePermissions'; import usePrevious from '@hooks/usePrevious'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; diff --git a/src/components/LHNOptionsList/OptionRowLHNData.tsx b/src/components/LHNOptionsList/OptionRowLHNData.tsx index fdc6208310cd..a0dc3e6270ae 100644 --- a/src/components/LHNOptionsList/OptionRowLHNData.tsx +++ b/src/components/LHNOptionsList/OptionRowLHNData.tsx @@ -58,18 +58,7 @@ function OptionRowLHNData({ // Listen parentReportAction to update title of thread report when parentReportAction changed // Listen to transaction to update title of transaction report when transaction changed // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps - }, [ - fullReport, - lastReportActionTransaction, - reportActions, - personalDetails, - preferredLocale, - policy, - parentReportAction, - transaction, - transactionViolations, - receiptTransactions, - ]); + }, [fullReport, lastReportActionTransaction, reportActions, personalDetails, preferredLocale, policy, parentReportAction, transaction, transactionViolations, receiptTransactions]); return ( ({...ReceiptUtils.getThumbnailAndImageURIs(transaction), transaction})); diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 6f42827bc506..e4b335e7440c 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -18,7 +18,6 @@ import * as LocalePhoneNumber from './LocalePhoneNumber'; import * as Localize from './Localize'; import * as OptionsListUtils from './OptionsListUtils'; import Parser from './Parser'; -import Permissions from './Permissions'; import * as PolicyUtils from './PolicyUtils'; import * as ReportActionsUtils from './ReportActionsUtils'; import * as ReportUtils from './ReportUtils'; @@ -26,12 +25,6 @@ import * as TaskUtils from './TaskUtils'; type WelcomeMessage = {showReportName: boolean; phrase1?: string; phrase2?: string; phrase3?: string; messageText?: string; messageHtml?: string}; -let allBetas: OnyxEntry; -Onyx.connect({ - key: ONYXKEYS.BETAS, - callback: (value) => (allBetas = value), -}); - const visibleReportActionItems: ReportActions = {}; let allPersonalDetails: OnyxEntry; Onyx.connect({ diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 074cdf9c838d..6f65a648836e 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -40,7 +40,6 @@ import * as LocalePhoneNumber from '@libs/LocalePhoneNumber'; import * as Localize from '@libs/Localize'; import Navigation from '@libs/Navigation/Navigation'; import * as NextStepUtils from '@libs/NextStepUtils'; -import Permissions from '@libs/Permissions'; import * as PhoneNumber from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; @@ -154,12 +153,6 @@ type GPSPoint = { long: number; }; -let betas: OnyxTypes.Beta[] = []; -Onyx.connect({ - key: ONYXKEYS.BETAS, - callback: (value) => (betas = value ?? []), -}); - let allPersonalDetails: OnyxTypes.PersonalDetailsList = {}; Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, From 301fe8572575d965cc9b8a395a46b8b5293f9f69 Mon Sep 17 00:00:00 2001 From: Shridhar Goel <35566748+ShridharGoel@users.noreply.github.com> Date: Thu, 25 Jul 2024 01:59:14 +0530 Subject: [PATCH 5/8] Include a comment back --- src/libs/actions/IOU.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 458274610243..9f390425ddf2 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5518,6 +5518,7 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo }); } + // added the operation to delete associated transaction violations onyxUpdates.push({ onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, From 2f1708f96f67079f3a528372acda4004fca56ccc Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:37:36 +0530 Subject: [PATCH 6/8] Lint fix --- src/components/ReportActionItem/ReportPreview.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index a26ac113df7a..570fad5bb9d4 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -152,7 +152,8 @@ function ReportPreview({ const hasErrors = hasMissingSmartscanFields || // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - (ReportUtils.hasViolations(iouReportID, transactionViolations) || ReportUtils.hasWarningTypeViolations(iouReportID, transactionViolations)) || + ReportUtils.hasViolations(iouReportID, transactionViolations) || + ReportUtils.hasWarningTypeViolations(iouReportID, transactionViolations) || (ReportUtils.isReportOwner(iouReport) && ReportUtils.hasReportViolations(iouReportID)) || ReportUtils.hasActionsWithErrors(iouReportID); const lastThreeTransactionsWithReceipts = transactionsWithReceipts.slice(-3); From d11779abc19baf8414ed6f2c6117adffd8156ec6 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:12:18 +0530 Subject: [PATCH 7/8] Update --- tests/unit/SidebarOrderTest.ts | 2 +- tests/unit/SidebarTest.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/SidebarOrderTest.ts b/tests/unit/SidebarOrderTest.ts index 96a5e0271e7b..b8a507289e8d 100644 --- a/tests/unit/SidebarOrderTest.ts +++ b/tests/unit/SidebarOrderTest.ts @@ -10,7 +10,7 @@ import * as LHNTestUtils from '../utils/LHNTestUtils'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates'; -// Be sure to include the mocked Permissions and Expensicons libraries as well as the usePermissions hook or else the beta tests won't work +// Be sure to include the mocked Permissions and Expensicons libraries or else the beta tests won't work jest.mock('@libs/Permissions'); jest.mock('@components/Icon/Expensicons'); jest.mock('@src/hooks/useActiveWorkspaceFromNavigationState'); diff --git a/tests/unit/SidebarTest.ts b/tests/unit/SidebarTest.ts index 5df2dcd964ca..6913d39b7f34 100644 --- a/tests/unit/SidebarTest.ts +++ b/tests/unit/SidebarTest.ts @@ -10,7 +10,7 @@ import * as LHNTestUtils from '../utils/LHNTestUtils'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates'; -// Be sure to include the mocked Permissions and Expensicons libraries as well as the usePermissions hook or else the beta tests won't work +// Be sure to include the mocked Permissions and Expensicons libraries or else the beta tests won't work jest.mock('@src/libs/Permissions'); jest.mock('@src/hooks/useActiveWorkspaceFromNavigationState'); jest.mock('@src/components/Icon/Expensicons'); From be66288df4f249abb1b27fa68ae0dc4b3e1b3bf5 Mon Sep 17 00:00:00 2001 From: Shridhar Goel <35566748+ShridharGoel@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:07:44 +0530 Subject: [PATCH 8/8] Lint fix --- src/libs/OptionsListUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 6d6015abbeb6..e15d8aa41278 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -49,7 +49,6 @@ import * as LoginUtils from './LoginUtils'; import ModifiedExpenseMessage from './ModifiedExpenseMessage'; import Navigation from './Navigation/Navigation'; import Performance from './Performance'; -import Permissions from './Permissions'; import * as PersonalDetailsUtils from './PersonalDetailsUtils'; import * as PhoneNumber from './PhoneNumber'; import * as PolicyUtils from './PolicyUtils';