From b59bcf38af815847b42e35a278194ad166f14e97 Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 10 Mar 2026 10:31:53 +0700 Subject: [PATCH 01/15] remove ONYXKEYS.COLLECTION.REPORT_VIOLATIONS --- src/ONYXKEYS.ts | 1 - .../MoneyRequestViewReportFields.tsx | 6 +-- .../ReportActionItem/MoneyReportView.tsx | 4 +- .../TransactionPreviewContent.tsx | 4 +- src/libs/ReportUtils.ts | 22 +--------- src/libs/TransactionPreviewUtils.ts | 5 +-- src/libs/actions/IOU/index.ts | 43 +------------------ src/libs/actions/Report/index.ts | 18 +------- src/pages/Debug/Report/DebugReportPage.tsx | 7 +-- src/pages/EditReportFieldPage.tsx | 2 - src/types/onyx/ReportViolation.ts | 21 --------- src/types/onyx/index.ts | 2 - tests/unit/TransactionPreviewUtils.test.ts | 23 ---------- 13 files changed, 11 insertions(+), 147 deletions(-) delete mode 100644 src/types/onyx/ReportViolation.ts diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 44eeb2f50b740..bda7ef7ef1d72 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -1202,7 +1202,6 @@ type OnyxCollectionValuesMapping = { [ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING]: OnyxTypes.ReportUserIsTyping; [ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE]: OnyxTypes.PendingConciergeResponse; [ONYXKEYS.COLLECTION.REPORT_USER_IS_LEAVING_ROOM]: boolean; - [ONYXKEYS.COLLECTION.REPORT_VIOLATIONS]: OnyxTypes.ReportViolations; [ONYXKEYS.COLLECTION.SECURITY_GROUP]: OnyxTypes.SecurityGroup; [ONYXKEYS.COLLECTION.TRANSACTION]: OnyxTypes.Transaction; [ONYXKEYS.COLLECTION.TRANSACTION_DRAFT]: OnyxTypes.Transaction; diff --git a/src/components/MoneyRequestReportView/MoneyRequestViewReportFields.tsx b/src/components/MoneyRequestReportView/MoneyRequestViewReportFields.tsx index 0c4abfbdf46b4..6d3adfec6cecd 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestViewReportFields.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestViewReportFields.tsx @@ -82,8 +82,6 @@ function ReportFieldView(reportField: EnrichedPolicyReportField, report: OnyxEnt function MoneyRequestViewReportFields({report, policy, isCombinedReport = false, pendingAction}: MoneyRequestViewReportFieldsProps) { const styles = useThemeStyles(); - const [violations] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_VIOLATIONS}${report?.reportID}`); - const sortedPolicyReportFields = useMemo((): EnrichedPolicyReportField[] => { const {fieldValues, fieldsByName} = getReportFieldMaps(report, policy?.fieldList ?? {}); const fields = Object.values(fieldsByName); @@ -98,7 +96,7 @@ function MoneyRequestViewReportFields({report, policy, isCombinedReport = false, const isDeletedFormulaField = field.type === CONST.REPORT_FIELD_TYPES.FORMULA && field.deletable; const fieldKey = getReportFieldKey(field.fieldID); - const violation = isFieldDisabled ? undefined : getFieldViolation(violations, field); + const violation = isFieldDisabled ? undefined : getFieldViolation(field); const violationTranslation = getFieldViolationTranslation(field, violation); return { @@ -110,7 +108,7 @@ function MoneyRequestViewReportFields({report, policy, isCombinedReport = false, violationTranslation, }; }); - }, [policy, report, violations]); + }, [policy, report]); const enabledReportFields = sortedPolicyReportFields.filter( (reportField) => !isReportFieldDisabled(report, reportField, policy) || reportField.type === CONST.REPORT_FIELD_TYPES.FORMULA, diff --git a/src/components/ReportActionItem/MoneyReportView.tsx b/src/components/ReportActionItem/MoneyReportView.tsx index c6544ec325b41..6607bd6888d7e 100644 --- a/src/components/ReportActionItem/MoneyReportView.tsx +++ b/src/components/ReportActionItem/MoneyReportView.tsx @@ -109,8 +109,6 @@ function MoneyReportView({ StyleUtils.getColorStyle(theme.textSupporting), ]; - const [violations] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_VIOLATIONS}${report?.reportID}`); - const {sortedPolicyReportFields, fieldValues, fieldsByName} = useMemo(() => { const {fieldValues: values, fieldsByName: byName} = getReportFieldMaps(report, policy?.fieldList ?? {}); const sorted = Object.values(byName) @@ -170,7 +168,7 @@ function MoneyReportView({ const isFieldDisabled = isReportFieldDisabledForUser(report, reportField, policy); const fieldKey = getReportFieldKey(reportField.fieldID); - const violation = isFieldDisabled ? undefined : getFieldViolation(violations, reportField); + const violation = isFieldDisabled ? undefined : getFieldViolation(reportField); const violationTranslation = getFieldViolationTranslation(reportField, violation); return ( diff --git a/src/components/ReportActionItem/TransactionPreview/TransactionPreviewContent.tsx b/src/components/ReportActionItem/TransactionPreview/TransactionPreviewContent.tsx index 30e3dede2eaff..9104d3d8cdaad 100644 --- a/src/components/ReportActionItem/TransactionPreview/TransactionPreviewContent.tsx +++ b/src/components/ReportActionItem/TransactionPreview/TransactionPreviewContent.tsx @@ -72,7 +72,6 @@ function TransactionPreviewContent({ const styles = useThemeStyles(); const {translate} = useLocalize(); const {environmentURL} = useEnvironment(); - const [reportViolations] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_VIOLATIONS}${getNonEmptyStringOnyxID(report?.reportID)}`); const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`); const isParentPolicyExpenseChat = isPolicyExpenseChat(chatReport); const transactionDetails = useMemo>( @@ -114,9 +113,8 @@ function TransactionPreviewContent({ currentUserEmail, currentUserAccountID, reportActions, - reportViolations, }), - [areThereDuplicates, transactionPreviewCommonArguments, isReportAPolicyExpenseChat, currentUserEmail, currentUserAccountID, reportActions, reportViolations], + [areThereDuplicates, transactionPreviewCommonArguments, isReportAPolicyExpenseChat, currentUserEmail, currentUserAccountID, reportActions], ); const {shouldShowRBR, shouldShowMerchant, shouldShowSplitShare, shouldShowTag, shouldShowCategory, shouldShowSkeleton, shouldShowDescription} = conditionals; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 21f2fd9bccc7e..89c0bad6687e2 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -56,7 +56,6 @@ import type { ReportMetadata, ReportNameValuePairs, ReportViolationName, - ReportViolations, Task, Transaction, TransactionViolation, @@ -9249,13 +9248,6 @@ function hasAnyViolations( ); } -function hasReportViolations(reportViolations: OnyxEntry) { - if (!reportViolations) { - return false; - } - return Object.values(reportViolations ?? {}).some((violations) => !isEmptyObject(violations)); -} - /** * Checks if submission should be blocked due to strict policy rules being enabled and violations present. * When a user's domain has "strictly enforce workspace rules" enabled, they cannot submit reports with violations. @@ -12330,23 +12322,13 @@ function getChatUsedForOnboarding(onboardingValue: OnyxEntry, concie /** * Checks if given field has any violations and returns name of the first encountered one */ -function getFieldViolation(violations: OnyxEntry, reportField: PolicyReportField): ReportViolationName | undefined { +function getFieldViolation(reportField: PolicyReportField): ReportViolationName | undefined { if (!reportField) { return undefined; } - if (!violations) { - return (reportField.value ?? reportField.defaultValue) ? undefined : CONST.REPORT_VIOLATIONS.FIELD_REQUIRED; - } - - const fieldViolation = Object.values(CONST.REPORT_VIOLATIONS).find((violation) => !!violations[violation] && violations[violation][reportField.fieldID]); - - // If the field has no value or no violation, we return 'fieldRequired' violation - if (!fieldViolation) { - return reportField.value ? undefined : CONST.REPORT_VIOLATIONS.FIELD_REQUIRED; - } + return (reportField.value ?? reportField.defaultValue) ? undefined : CONST.REPORT_VIOLATIONS.FIELD_REQUIRED; - return fieldViolation; } /** diff --git a/src/libs/TransactionPreviewUtils.ts b/src/libs/TransactionPreviewUtils.ts index 349df6f990ef0..1a0f32b07731d 100644 --- a/src/libs/TransactionPreviewUtils.ts +++ b/src/libs/TransactionPreviewUtils.ts @@ -368,7 +368,6 @@ function getTransactionPreviewTextAndTranslationPaths({ } function createTransactionPreviewConditionals({ - reportViolations, iouReport, policy, transaction, @@ -382,7 +381,6 @@ function createTransactionPreviewConditionals({ currentUserAccountID, reportActions, }: { - reportViolations: OnyxEntry; iouReport: OnyxEntry; policy: OnyxEntry; transaction: OnyxEntry | undefined; @@ -433,8 +431,7 @@ function createTransactionPreviewConditionals({ (violation) => violation.name === CONST.VIOLATIONS.MODIFIED_AMOUNT && (violation.type === CONST.VIOLATION_TYPES.VIOLATION || violation.type === CONST.VIOLATION_TYPES.NOTICE), )); const hasErrorOrOnHold = hasFieldErrors || (!isFullySettled && !isFullyApproved && isTransactionOnHold); - const hasReportViolationsOrActionErrors = - (isReportOwner(iouReport) && hasReportViolations(reportViolations)) || hasActionWithErrorsForTransaction(iouReport?.reportID, transaction, reportActions); + const hasReportViolationsOrActionErrors = hasActionWithErrorsForTransaction(iouReport?.reportID, transaction, reportActions); const isDEWSubmitFailed = hasDynamicExternalWorkflow(policy) && !!getMostRecentActiveDEWSubmitFailedAction(reportActions); const shouldShowRBR = hasAnyViolations || hasErrorOrOnHold || hasReportViolationsOrActionErrors || hasReceiptError(transaction) || isDEWSubmitFailed; diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index c449ca8168fb5..058175f5e3a02 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -1908,39 +1908,6 @@ function getReceiptError( ); } -/** Helper function to get optimistic fields violations onyx data */ -function getFieldViolationsOnyxData(iouReport: OnyxTypes.Report): OnyxData { - const missingFields: OnyxTypes.ReportFieldsViolations = {}; - const excludedFields = Object.values(CONST.REPORT_VIOLATIONS_EXCLUDED_FIELDS) as string[]; - - for (const field of Object.values(iouReport.fieldList ?? {})) { - if (excludedFields.includes(field.fieldID) || !!field.value || !!field.defaultValue) { - continue; - } - // in case of missing field violation the empty object is indicator. - missingFields[field.fieldID] = {}; - } - - return { - optimisticData: [ - { - onyxMethod: Onyx.METHOD.SET, - key: `${ONYXKEYS.COLLECTION.REPORT_VIOLATIONS}${iouReport.reportID}`, - value: { - fieldRequired: missingFields, - }, - }, - ], - failureData: [ - { - onyxMethod: Onyx.METHOD.SET, - key: `${ONYXKEYS.COLLECTION.REPORT_VIOLATIONS}${iouReport.reportID}`, - value: null, - }, - ], - }; -} - type BuildOnyxDataForTestDriveIOUParams = { transaction: OnyxTypes.Transaction; iouOptimisticParams: MoneyRequestOptimisticParams['iou']; @@ -2728,8 +2695,7 @@ type BuildOnyxDataForTrackExpenseKeys = | typeof ONYXKEYS.COLLECTION.TRANSACTION | typeof ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE | typeof ONYXKEYS.COLLECTION.SNAPSHOT - | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS - | typeof ONYXKEYS.COLLECTION.REPORT_VIOLATIONS; + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS; /** Builds the Onyx data for track expense */ function buildOnyxDataForTrackExpense({ @@ -3150,13 +3116,6 @@ function buildOnyxDataForTrackExpense({ }); } - // Show field violations only for control policies - if (isControlPolicy(policy) && iouReport) { - const {optimisticData: fieldViolationsOptimisticData, failureData: fieldViolationsFailureData} = getFieldViolationsOnyxData(iouReport); - onyxData.optimisticData?.push(...(fieldViolationsOptimisticData ?? [])); - onyxData.failureData?.push(...(fieldViolationsFailureData ?? [])); - } - return onyxData; } diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index bed96b0e0ca75..849a2d2856dec 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -209,7 +209,6 @@ import type { ReportActionReactions, ReportNextStepDeprecated, ReportUserIsTyping, - ReportViolations, Transaction, TransactionViolations, VisibleReportActionsDerivedValue, @@ -2970,7 +2969,6 @@ function updateReportField({ email, hasViolationsParam, recentlyUsedReportFields, - reportViolations, shouldFixViolations = false, }: { report: Report; @@ -2982,12 +2980,11 @@ function updateReportField({ email: string; hasViolationsParam: boolean; recentlyUsedReportFields: OnyxEntry; - reportViolations: OnyxEntry; shouldFixViolations: boolean | undefined; }) { const reportID = report.reportID; const fieldKey = getReportFieldKey(reportField.fieldID); - const fieldViolation = getFieldViolation(reportViolations, reportField); + const fieldViolation = getFieldViolation(reportField); const recentlyUsedValues = recentlyUsedReportFields?.[fieldKey] ?? []; const optimisticChangeFieldAction = buildOptimisticChangeFieldAction(reportField, previousReportField); @@ -3021,7 +3018,6 @@ function updateReportField({ | typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.NEXT_STEP | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS - | typeof ONYXKEYS.COLLECTION.REPORT_VIOLATIONS | typeof ONYXKEYS.RECENTLY_USED_REPORT_FIELDS > > = [ @@ -3053,18 +3049,6 @@ function updateReportField({ }, ]; - if (fieldViolation) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_VIOLATIONS}${reportID}`, - value: { - [fieldViolation]: { - [reportField.fieldID]: null, - }, - }, - }); - } - if (reportField.type === 'dropdown' && reportField.value) { optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, diff --git a/src/pages/Debug/Report/DebugReportPage.tsx b/src/pages/Debug/Report/DebugReportPage.tsx index 2ba3169c34bb2..3d73b3d281273 100644 --- a/src/pages/Debug/Report/DebugReportPage.tsx +++ b/src/pages/Debug/Report/DebugReportPage.tsx @@ -21,7 +21,7 @@ import DebugTabNavigator from '@libs/Navigation/DebugTabNavigator'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {DebugParamList} from '@libs/Navigation/types'; -import {hasReportViolations, isReportOwner, shouldDisplayViolationsRBRInLHN} from '@libs/ReportUtils'; +import {shouldDisplayViolationsRBRInLHN} from '@libs/ReportUtils'; import DebugDetails from '@pages/Debug/DebugDetails'; import DebugJSON from '@pages/Debug/DebugJSON'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; @@ -59,7 +59,6 @@ function DebugReportPage({ const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`); const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS); - const [reportViolations] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_VIOLATIONS}${reportID}`); const reportAttributesSelector = useCallback((attributes: OnyxEntry) => attributes?.reports?.[reportID], [reportID]); const [reportAttributes] = useOnyx( ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, @@ -83,8 +82,7 @@ function DebugReportPage({ } const shouldDisplayViolations = shouldDisplayViolationsRBRInLHN(report, transactionViolations); - const shouldDisplayReportViolations = isReportOwner(report) && hasReportViolations(reportViolations); - const hasViolations = !!shouldDisplayViolations || shouldDisplayReportViolations; + const hasViolations = !!shouldDisplayViolations; const {reason: reasonGBR, reportAction: reportActionGBR} = DebugUtils.getReasonAndReportActionForGBRInLHNRow(report, isReportArchived) ?? {}; const {reason: reasonRBR, reportAction: reportActionRBR} = DebugUtils.getReasonAndReportActionForRBRInLHNRow( @@ -156,7 +154,6 @@ function DebugReportPage({ }, [ report, transactionViolations, - reportViolations, isReportArchived, chatReport, reportActions, diff --git a/src/pages/EditReportFieldPage.tsx b/src/pages/EditReportFieldPage.tsx index 7ff09c307da9e..c0dfedbef248f 100644 --- a/src/pages/EditReportFieldPage.tsx +++ b/src/pages/EditReportFieldPage.tsx @@ -68,7 +68,6 @@ function EditReportFieldPage({route}: EditReportFieldPageProps) { const session = useSession(); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS); const hasViolations = hasViolationsReportUtils(report?.reportID, transactionViolations, session?.accountID ?? CONST.DEFAULT_NUMBER_ID, session?.email ?? ''); - const [reportViolations] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_VIOLATIONS}${reportID}`); const {translate} = useLocalize(); const {showConfirmModal} = useConfirmModal(); const icons = useMemoizedLazyExpensifyIcons(['Trashcan'] as const); @@ -142,7 +141,6 @@ function EditReportFieldPage({route}: EditReportFieldPageProps) { email: session?.email ?? '', hasViolationsParam: hasViolations, recentlyUsedReportFields, - reportViolations, shouldFixViolations: hasOtherViolations ?? false, }); } diff --git a/src/types/onyx/ReportViolation.ts b/src/types/onyx/ReportViolation.ts deleted file mode 100644 index fae385cc674d9..0000000000000 --- a/src/types/onyx/ReportViolation.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type {EmptyObject, ValueOf} from 'type-fest'; -import type CONST from '@src/CONST'; - -/** - * Names of violations. - * Derived from `CONST.VIOLATIONS` to maintain a single source of truth. - */ -type ReportViolationName = ValueOf; - -/** - * Keys of this object are IDs of field that has violations - */ -type ReportFieldsViolations = Record; - -/** - * Report Violation model - */ -type ReportViolations = Record; - -export type {ReportViolationName, ReportFieldsViolations}; -export default ReportViolations; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index 07b1e30bf1dd9..ae33e1e160240 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -134,7 +134,6 @@ import type LastSearchParams from './ReportNavigation'; import type ReportNextStepDeprecated from './ReportNextStepDeprecated'; import type ReportUserIsTyping from './ReportUserIsTyping'; import type {ReportFieldsViolations, ReportViolationName} from './ReportViolation'; -import type ReportViolations from './ReportViolation'; import type Request from './Request'; import type {AnyRequest} from './Request'; import type Response from './Response'; @@ -279,7 +278,6 @@ export type { ReportMetadata, ReportNextStepDeprecated, ReportViolationName, - ReportViolations, ReportFieldsViolations, ReportLayoutGroupBy, GroupedTransactions, diff --git a/tests/unit/TransactionPreviewUtils.test.ts b/tests/unit/TransactionPreviewUtils.test.ts index 184d9e0a1b39a..d71a63368e524 100644 --- a/tests/unit/TransactionPreviewUtils.test.ts +++ b/tests/unit/TransactionPreviewUtils.test.ts @@ -13,7 +13,6 @@ import CONST from '@src/CONST'; import * as ReportUtils from '@src/libs/ReportUtils'; import ONYXKEYS from '@src/ONYXKEYS'; import type {ReportActions, Transaction} from '@src/types/onyx'; -import type ReportViolations from '@src/types/onyx/ReportViolation'; import createRandomPolicy from '../utils/collections/policies'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; @@ -522,17 +521,9 @@ describe('TransactionPreviewUtils', () => { ownerAccountID: currentUserAccountID, }; - const reportViolations: ReportViolations = { - fieldRequired: { - field1: {}, - field2: {}, - }, - } as unknown as ReportViolations; - const functionArgs = { ...basicProps, iouReport, - reportViolations, violations: [], transaction: {...basicProps.transaction, errors: undefined, errorFields: undefined}, }; @@ -562,17 +553,10 @@ describe('TransactionPreviewUtils', () => { const resultWithoutViolations = createTransactionPreviewConditionals(functionArgsWithoutViolations); const shouldShowRBRWithoutViolations = resultWithoutViolations.shouldShowRBR; - // Then, test with violations - const reportViolations: ReportViolations = { - fieldRequired: { - field1: {}, - }, - } as unknown as ReportViolations; const functionArgsWithViolations = { ...basicProps, iouReport, - reportViolations, violations: [], transaction: {...basicProps.transaction, errors: undefined, errorFields: undefined}, }; @@ -590,16 +574,9 @@ describe('TransactionPreviewUtils', () => { ownerAccountID: currentUserAccountID, }; - const reportViolations: ReportViolations = { - fieldRequired: { - merchant: {}, - }, - } as unknown as ReportViolations; - const functionArgs = { ...basicProps, iouReport, - reportViolations, violations: [], // No transaction violations transaction: {...basicProps.transaction, errors: undefined, errorFields: undefined}, }; From 0a77e483662ff89b3bdb95ccf3de40816db21193 Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 10 Mar 2026 10:35:00 +0700 Subject: [PATCH 02/15] prettier --- src/libs/ReportUtils.ts | 1 - src/libs/actions/Report/index.ts | 7 +------ src/pages/Debug/Report/DebugReportPage.tsx | 14 +------------- tests/unit/TransactionPreviewUtils.test.ts | 1 - 4 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 89c0bad6687e2..46024e531fa7a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -12328,7 +12328,6 @@ function getFieldViolation(reportField: PolicyReportField): ReportViolationName } return (reportField.value ?? reportField.defaultValue) ? undefined : CONST.REPORT_VIOLATIONS.FIELD_REQUIRED; - } /** diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index 849a2d2856dec..3501cf80347c9 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -3014,12 +3014,7 @@ function updateReportField({ }); const optimisticData: Array< - OnyxUpdate< - | typeof ONYXKEYS.COLLECTION.REPORT - | typeof ONYXKEYS.COLLECTION.NEXT_STEP - | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS - | typeof ONYXKEYS.RECENTLY_USED_REPORT_FIELDS - > + OnyxUpdate > = [ { onyxMethod: Onyx.METHOD.MERGE, diff --git a/src/pages/Debug/Report/DebugReportPage.tsx b/src/pages/Debug/Report/DebugReportPage.tsx index 3d73b3d281273..de56cf4a1b980 100644 --- a/src/pages/Debug/Report/DebugReportPage.tsx +++ b/src/pages/Debug/Report/DebugReportPage.tsx @@ -151,19 +151,7 @@ function DebugReportPage({ : undefined, }, ]; - }, [ - report, - transactionViolations, - isReportArchived, - chatReport, - reportActions, - transactions, - reportAttributes?.reportErrors, - betas, - priorityMode, - draftComment, - translate, - ]); + }, [report, transactionViolations, isReportArchived, chatReport, reportActions, transactions, reportAttributes?.reportErrors, betas, priorityMode, draftComment, translate]); const icons = useMemoizedLazyExpensifyIcons(['Eye'] as const); diff --git a/tests/unit/TransactionPreviewUtils.test.ts b/tests/unit/TransactionPreviewUtils.test.ts index d71a63368e524..f60fd841b6f91 100644 --- a/tests/unit/TransactionPreviewUtils.test.ts +++ b/tests/unit/TransactionPreviewUtils.test.ts @@ -553,7 +553,6 @@ describe('TransactionPreviewUtils', () => { const resultWithoutViolations = createTransactionPreviewConditionals(functionArgsWithoutViolations); const shouldShowRBRWithoutViolations = resultWithoutViolations.shouldShowRBR; - const functionArgsWithViolations = { ...basicProps, iouReport, From d53023806ad5dc0729954a6f50c99d1e1fbdad2e Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 10 Mar 2026 10:40:45 +0700 Subject: [PATCH 03/15] update Onyx type --- .../MoneyRequestViewReportFields.tsx | 2 -- src/libs/ReportUtils.ts | 1 - src/libs/TransactionPreviewUtils.ts | 2 -- src/types/onyx/ReportViolation.ts | 21 +++++++++++++++++++ src/types/onyx/index.ts | 2 ++ 5 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 src/types/onyx/ReportViolation.ts diff --git a/src/components/MoneyRequestReportView/MoneyRequestViewReportFields.tsx b/src/components/MoneyRequestReportView/MoneyRequestViewReportFields.tsx index 6d3adfec6cecd..564a6a121327b 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestViewReportFields.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestViewReportFields.tsx @@ -4,7 +4,6 @@ import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; -import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; import {clearReportFieldKeyErrors} from '@libs/actions/Report'; import {resolveReportFieldValue} from '@libs/Formula'; @@ -23,7 +22,6 @@ import { } from '@libs/ReportUtils'; import type {ThemeStyles} from '@styles/index'; import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {Policy, PolicyReportField, Report, ReportViolationName} from '@src/types/onyx'; import type {PendingAction} from '@src/types/onyx/OnyxCommon'; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 46024e531fa7a..4244db8e93f2e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -13405,7 +13405,6 @@ export { getMostRecentlyVisitedReport, getSourceIDFromReportAction, getIntegrationNameFromExportMessage, - hasReportViolations, isPayAtEndExpenseReport, getApprovalChain, isIndividualInvoiceRoom, diff --git a/src/libs/TransactionPreviewUtils.ts b/src/libs/TransactionPreviewUtils.ts index 1a0f32b07731d..2b593837fff88 100644 --- a/src/libs/TransactionPreviewUtils.ts +++ b/src/libs/TransactionPreviewUtils.ts @@ -14,11 +14,9 @@ import {getMostRecentActiveDEWSubmitFailedAction, getOriginalMessage, isDynamicE import { hasActionWithErrorsForTransaction, hasReceiptError, - hasReportViolations, isPaidGroupPolicyExpenseReport, isPaidGroupPolicy as isPaidGroupPolicyUtil, isReportApproved, - isReportOwner, isSettled, } from './ReportUtils'; import type {TransactionDetails} from './ReportUtils'; diff --git a/src/types/onyx/ReportViolation.ts b/src/types/onyx/ReportViolation.ts new file mode 100644 index 0000000000000..77c87737b023d --- /dev/null +++ b/src/types/onyx/ReportViolation.ts @@ -0,0 +1,21 @@ +import type {EmptyObject, ValueOf} from 'type-fest'; +import type CONST from '@src/CONST'; + +/** + * Names of violations. + * Derived from `CONST.VIOLATIONS` to maintain a single source of truth. + */ +type ReportViolationName = ValueOf; + +/** + * Keys of this object are IDs of field that has violations + */ +type ReportFieldsViolations = Record; + +/** + * Report Violation model + */ +type ReportViolations = Record; + +export type {ReportViolationName, ReportFieldsViolations}; +export default ReportViolations; \ No newline at end of file diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index ae33e1e160240..07b1e30bf1dd9 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -134,6 +134,7 @@ import type LastSearchParams from './ReportNavigation'; import type ReportNextStepDeprecated from './ReportNextStepDeprecated'; import type ReportUserIsTyping from './ReportUserIsTyping'; import type {ReportFieldsViolations, ReportViolationName} from './ReportViolation'; +import type ReportViolations from './ReportViolation'; import type Request from './Request'; import type {AnyRequest} from './Request'; import type Response from './Response'; @@ -278,6 +279,7 @@ export type { ReportMetadata, ReportNextStepDeprecated, ReportViolationName, + ReportViolations, ReportFieldsViolations, ReportLayoutGroupBy, GroupedTransactions, From bf5b4c45a49d2a3d8da514f871c54532452fbd1e Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 10 Mar 2026 10:54:34 +0700 Subject: [PATCH 04/15] lint --- src/components/ReportActionItem/MoneyReportView.tsx | 2 -- src/libs/TransactionPreviewUtils.ts | 9 +-------- src/libs/actions/IOU/index.ts | 1 - src/libs/actions/Report/index.ts | 1 - src/types/onyx/ReportViolation.ts | 6 ------ src/types/onyx/index.ts | 2 -- 6 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/components/ReportActionItem/MoneyReportView.tsx b/src/components/ReportActionItem/MoneyReportView.tsx index 6607bd6888d7e..945429d343e78 100644 --- a/src/components/ReportActionItem/MoneyReportView.tsx +++ b/src/components/ReportActionItem/MoneyReportView.tsx @@ -13,7 +13,6 @@ import UnreadActionIndicator from '@components/UnreadActionIndicator'; import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; -import useOnyx from '@hooks/useOnyx'; import useReportTransactions from '@hooks/useReportTransactions'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; @@ -45,7 +44,6 @@ import variables from '@styles/variables'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import {clearReportFieldKeyErrors} from '@src/libs/actions/Report'; -import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {Policy, Report} from '@src/types/onyx'; import type {PendingAction} from '@src/types/onyx/OnyxCommon'; diff --git a/src/libs/TransactionPreviewUtils.ts b/src/libs/TransactionPreviewUtils.ts index 2b593837fff88..ce01f0d59bf9f 100644 --- a/src/libs/TransactionPreviewUtils.ts +++ b/src/libs/TransactionPreviewUtils.ts @@ -11,14 +11,7 @@ import {convertToDisplayString} from './CurrencyUtils'; import DateUtils from './DateUtils'; import {hasDynamicExternalWorkflow} from './PolicyUtils'; import {getMostRecentActiveDEWSubmitFailedAction, getOriginalMessage, isDynamicExternalWorkflowSubmitFailedAction, isMessageDeleted, isMoneyRequestAction} from './ReportActionsUtils'; -import { - hasActionWithErrorsForTransaction, - hasReceiptError, - isPaidGroupPolicyExpenseReport, - isPaidGroupPolicy as isPaidGroupPolicyUtil, - isReportApproved, - isSettled, -} from './ReportUtils'; +import {hasActionWithErrorsForTransaction, hasReceiptError, isPaidGroupPolicyExpenseReport, isPaidGroupPolicy as isPaidGroupPolicyUtil, isReportApproved, isSettled} from './ReportUtils'; import type {TransactionDetails} from './ReportUtils'; import StringUtils from './StringUtils'; import { diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index 058175f5e3a02..181bb202ca883 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -84,7 +84,6 @@ import { getSubmitToAccountID, hasDependentTags, hasDynamicExternalWorkflow, - isControlPolicy, isDelayedSubmissionEnabled, isPaidGroupPolicy, isPolicyAdmin, diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index 3501cf80347c9..2df3a52b04718 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -2984,7 +2984,6 @@ function updateReportField({ }) { const reportID = report.reportID; const fieldKey = getReportFieldKey(reportField.fieldID); - const fieldViolation = getFieldViolation(reportField); const recentlyUsedValues = recentlyUsedReportFields?.[fieldKey] ?? []; const optimisticChangeFieldAction = buildOptimisticChangeFieldAction(reportField, previousReportField); diff --git a/src/types/onyx/ReportViolation.ts b/src/types/onyx/ReportViolation.ts index 77c87737b023d..f8a80a54f1a23 100644 --- a/src/types/onyx/ReportViolation.ts +++ b/src/types/onyx/ReportViolation.ts @@ -12,10 +12,4 @@ type ReportViolationName = ValueOf; */ type ReportFieldsViolations = Record; -/** - * Report Violation model - */ -type ReportViolations = Record; - export type {ReportViolationName, ReportFieldsViolations}; -export default ReportViolations; \ No newline at end of file diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index 07b1e30bf1dd9..ae33e1e160240 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -134,7 +134,6 @@ import type LastSearchParams from './ReportNavigation'; import type ReportNextStepDeprecated from './ReportNextStepDeprecated'; import type ReportUserIsTyping from './ReportUserIsTyping'; import type {ReportFieldsViolations, ReportViolationName} from './ReportViolation'; -import type ReportViolations from './ReportViolation'; import type Request from './Request'; import type {AnyRequest} from './Request'; import type Response from './Response'; @@ -279,7 +278,6 @@ export type { ReportMetadata, ReportNextStepDeprecated, ReportViolationName, - ReportViolations, ReportFieldsViolations, ReportLayoutGroupBy, GroupedTransactions, From 82fca2739915fce8d109c55d14afceb3b4c3bbc3 Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 10 Mar 2026 10:57:12 +0700 Subject: [PATCH 05/15] linting --- src/libs/actions/Report/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index 2df3a52b04718..091027a0bfc02 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -127,7 +127,6 @@ import { getChatByParticipants, getChildReportNotificationPreference, getDefaultNotificationPreferenceForReport, - getFieldViolation, getLastVisibleMessage, getNextApproverAccountID, getOptimisticDataForAncestors, From 55210cc25b3212c1ee88f15070f363e2e3c4a89f Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 10 Mar 2026 11:06:31 +0700 Subject: [PATCH 06/15] update suggestions --- src/CONST/index.ts | 4 ---- src/ONYXKEYS.ts | 1 - src/types/onyx/index.ts | 3 +-- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index de2b333f87dab..55f8b475a5c5b 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -6238,10 +6238,6 @@ const CONST = { RBR_MESSAGE_MAX_CHARACTERS_FOR_PREVIEW: 40, }, - REPORT_VIOLATIONS_EXCLUDED_FIELDS: { - TEXT_TITLE: 'text_title', - }, - /** Context menu types */ CONTEXT_MENU_TYPES: { LINK: 'LINK', diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index bda7ef7ef1d72..2a34c735e6cc6 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -709,7 +709,6 @@ const ONYXKEYS = { REPORT_USER_IS_TYPING: 'reportUserIsTyping_', PENDING_CONCIERGE_RESPONSE: 'pendingConciergeResponse_', REPORT_USER_IS_LEAVING_ROOM: 'reportUserIsLeavingRoom_', - REPORT_VIOLATIONS: 'reportViolations_', SECURITY_GROUP: 'securityGroup_', TRANSACTION: 'transactions_', TRANSACTION_VIOLATIONS: 'transactionViolations_', diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index ae33e1e160240..b5e7294339975 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -133,7 +133,7 @@ import type ReportNameValuePairs from './ReportNameValuePairs'; import type LastSearchParams from './ReportNavigation'; import type ReportNextStepDeprecated from './ReportNextStepDeprecated'; import type ReportUserIsTyping from './ReportUserIsTyping'; -import type {ReportFieldsViolations, ReportViolationName} from './ReportViolation'; +import type {ReportViolationName} from './ReportViolation'; import type Request from './Request'; import type {AnyRequest} from './Request'; import type Response from './Response'; @@ -278,7 +278,6 @@ export type { ReportMetadata, ReportNextStepDeprecated, ReportViolationName, - ReportFieldsViolations, ReportLayoutGroupBy, GroupedTransactions, AnyRequest, From 8b0d2c921c7fbee69b35c6bac3d5bd93fe7a6226 Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 10 Mar 2026 11:19:17 +0700 Subject: [PATCH 07/15] Update tests --- src/types/onyx/ReportViolation.ts | 15 ----- src/types/onyx/ReportViolationName.ts | 12 ++++ src/types/onyx/index.ts | 2 +- tests/unit/TransactionPreviewUtils.test.ts | 71 ---------------------- 4 files changed, 13 insertions(+), 87 deletions(-) delete mode 100644 src/types/onyx/ReportViolation.ts create mode 100644 src/types/onyx/ReportViolationName.ts diff --git a/src/types/onyx/ReportViolation.ts b/src/types/onyx/ReportViolation.ts deleted file mode 100644 index f8a80a54f1a23..0000000000000 --- a/src/types/onyx/ReportViolation.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type {EmptyObject, ValueOf} from 'type-fest'; -import type CONST from '@src/CONST'; - -/** - * Names of violations. - * Derived from `CONST.VIOLATIONS` to maintain a single source of truth. - */ -type ReportViolationName = ValueOf; - -/** - * Keys of this object are IDs of field that has violations - */ -type ReportFieldsViolations = Record; - -export type {ReportViolationName, ReportFieldsViolations}; diff --git a/src/types/onyx/ReportViolationName.ts b/src/types/onyx/ReportViolationName.ts new file mode 100644 index 0000000000000..87816845ccd91 --- /dev/null +++ b/src/types/onyx/ReportViolationName.ts @@ -0,0 +1,12 @@ +import type {ValueOf} from 'type-fest'; +import type CONST from '@src/CONST'; + +/** + * Names of violations. + * Derived from `CONST.VIOLATIONS` to maintain a single source of truth. + */ +type ReportViolationName = ValueOf; + + + +export default ReportViolationName; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index b5e7294339975..91521b96e1063 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -133,7 +133,7 @@ import type ReportNameValuePairs from './ReportNameValuePairs'; import type LastSearchParams from './ReportNavigation'; import type ReportNextStepDeprecated from './ReportNextStepDeprecated'; import type ReportUserIsTyping from './ReportUserIsTyping'; -import type {ReportViolationName} from './ReportViolation'; +import type ReportViolationName from './ReportViolationName'; import type Request from './Request'; import type {AnyRequest} from './Request'; import type Response from './Response'; diff --git a/tests/unit/TransactionPreviewUtils.test.ts b/tests/unit/TransactionPreviewUtils.test.ts index f60fd841b6f91..2d5fee83289f6 100644 --- a/tests/unit/TransactionPreviewUtils.test.ts +++ b/tests/unit/TransactionPreviewUtils.test.ts @@ -513,77 +513,6 @@ describe('TransactionPreviewUtils', () => { expect(result.shouldShowRBR).toBeFalsy(); }); - it('should show RBR when report has violations and user is the report owner', () => { - const reportID = basicProps.iouReport.reportID || '1'; - const iouReport = { - ...basicProps.iouReport, - reportID, - ownerAccountID: currentUserAccountID, - }; - - const functionArgs = { - ...basicProps, - iouReport, - violations: [], - transaction: {...basicProps.transaction, errors: undefined, errorFields: undefined}, - }; - - const result = createTransactionPreviewConditionals(functionArgs); - expect(result.shouldShowRBR).toBeTruthy(); - }); - - it('should not show RBR from report violations when user is not the report owner', () => { - const reportID = basicProps.iouReport.reportID || '1'; - const otherUserAccountID = 888; - const iouReport = { - ...basicProps.iouReport, - reportID, - ownerAccountID: otherUserAccountID, - }; - - // First, test without violations - const functionArgsWithoutViolations = { - ...basicProps, - iouReport, - reportViolations: undefined, - violations: [], - transaction: {...basicProps.transaction, errors: undefined, errorFields: undefined}, - }; - - const resultWithoutViolations = createTransactionPreviewConditionals(functionArgsWithoutViolations); - const shouldShowRBRWithoutViolations = resultWithoutViolations.shouldShowRBR; - - const functionArgsWithViolations = { - ...basicProps, - iouReport, - violations: [], - transaction: {...basicProps.transaction, errors: undefined, errorFields: undefined}, - }; - - const resultWithViolations = createTransactionPreviewConditionals(functionArgsWithViolations); - // RBR should be the same with or without violations when user is not the owner - expect(resultWithViolations.shouldShowRBR).toBe(shouldShowRBRWithoutViolations); - }); - - it('should show RBR when report has violations even if transaction violations are absent', () => { - const reportID = basicProps.iouReport.reportID || '1'; - const iouReport = { - ...basicProps.iouReport, - reportID, - ownerAccountID: currentUserAccountID, - }; - - const functionArgs = { - ...basicProps, - iouReport, - violations: [], // No transaction violations - transaction: {...basicProps.transaction, errors: undefined, errorFields: undefined}, - }; - - const result = createTransactionPreviewConditionals(functionArgs); - expect(result.shouldShowRBR).toBeTruthy(); - }); - it('should show description if no merchant is presented and is not scanning', () => { const functionArgs = {...basicProps, transactionDetails: {comment: 'A valid comment', merchant: ''}}; const result = createTransactionPreviewConditionals(functionArgs); From aff39a07cad0e60d3d1b4be406e2209aa2cb92d7 Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 10 Mar 2026 11:24:56 +0700 Subject: [PATCH 08/15] prettier --- src/types/onyx/ReportViolationName.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/types/onyx/ReportViolationName.ts b/src/types/onyx/ReportViolationName.ts index 87816845ccd91..1635ff727d102 100644 --- a/src/types/onyx/ReportViolationName.ts +++ b/src/types/onyx/ReportViolationName.ts @@ -7,6 +7,4 @@ import type CONST from '@src/CONST'; */ type ReportViolationName = ValueOf; - - export default ReportViolationName; From 5617fa0525532c60cdbfc6f9b531ced55daa60c4 Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 12 Mar 2026 08:39:27 +0700 Subject: [PATCH 09/15] remove unnecessary code --- Mobile-Expensify | 2 +- src/libs/actions/IOU/index.ts | 25 ------------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index d04040c9f51f3..16295ce7472d4 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit d04040c9f51f31226fb0d48bc1513dd7b15ea526 +Subproject commit 16295ce7472d4977479b3be13b6bd7ad47b92c59 diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index d32f05925e468..c4d72b3ae2426 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -2934,31 +2934,6 @@ function buildOnyxDataForTrackExpense({ onyxData.successData?.push(...searchUpdate.successData); } } - - // We don't need to compute violations unless we're on a paid policy - if (!policy || !isPaidGroupPolicy(policy) || transaction.reportID === CONST.REPORT.UNREPORTED_REPORT_ID) { - return onyxData; - } - - const violationsOnyxData = ViolationsUtils.getViolationsOnyxData( - transaction, - [], - policy, - policyTagList ?? {}, - policyCategories ?? {}, - hasDependentTags(policy, policyTagList ?? {}), - false, - ); - - if (violationsOnyxData) { - onyxData.optimisticData?.push(violationsOnyxData); - onyxData.failureData?.push({ - onyxMethod: Onyx.METHOD.SET, - key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`, - value: [], - }); - } - return onyxData; } From 53eba9dd8a933711f41f8ad114727ca6c36e765e Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 12 Mar 2026 10:44:49 +0700 Subject: [PATCH 10/15] remove the rest ref of ONYXKEYS.COLLECTION.REPORT_VIOLATIONS --- src/libs/ReportUtils.ts | 4 ++-- src/libs/actions/OnyxDerived/configs/reportAttributes.ts | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index dcbbf4883d609..ec16135245484 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -13045,7 +13045,7 @@ function getReportFieldMaps(report: OnyxEntry, fieldList: Record, policy: OnyxEntry, reportViolations?: OnyxEntry): boolean { +function hasVisibleReportFieldViolations(report: OnyxEntry, policy: OnyxEntry): boolean { if (!report || !policy?.fieldList || !policy?.areReportFieldsEnabled) { return false; } @@ -13066,7 +13066,7 @@ function hasVisibleReportFieldViolations(report: OnyxEntry, policy: Onyx if (isReportFieldDisabledForUser(report, field, policy)) { return false; } - return !!getFieldViolation(reportViolations, field); + return !!getFieldViolation(field); }); } diff --git a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts index 899d8c5187817..744d85ba0b9f1 100644 --- a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts +++ b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts @@ -20,7 +20,6 @@ const prepareReportKeys = (keys: string[]) => { .replace(ONYXKEYS.COLLECTION.REPORT_METADATA, ONYXKEYS.COLLECTION.REPORT) .replace(ONYXKEYS.COLLECTION.REPORT_ACTIONS, ONYXKEYS.COLLECTION.REPORT) .replace(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, ONYXKEYS.COLLECTION.REPORT) - .replace(ONYXKEYS.COLLECTION.REPORT_VIOLATIONS, ONYXKEYS.COLLECTION.REPORT), ), ), ]; @@ -72,11 +71,10 @@ export default createOnyxDerivedValueConfig({ ONYXKEYS.SESSION, ONYXKEYS.COLLECTION.POLICY, ONYXKEYS.COLLECTION.POLICY_TAGS, - ONYXKEYS.COLLECTION.REPORT_VIOLATIONS, ONYXKEYS.COLLECTION.REPORT_METADATA, ], compute: ( - [reports, preferredLocale, transactionViolations, reportActions, reportNameValuePairs, transactions, personalDetails, session, policies, policyTags, reportViolations], + [reports, preferredLocale, transactionViolations, reportActions, reportNameValuePairs, transactions, personalDetails, session, policies, policyTags], {currentValue, sourceValues}, ) => { // Check if display names changed when personal details are updated @@ -107,7 +105,6 @@ export default createOnyxDerivedValueConfig({ const reportMetadataUpdates = sourceValues?.[ONYXKEYS.COLLECTION.REPORT_METADATA] ?? {}; const reportActionsUpdates = sourceValues?.[ONYXKEYS.COLLECTION.REPORT_ACTIONS] ?? {}; const reportNameValuePairsUpdates = sourceValues?.[ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS] ?? {}; - const reportViolationsUpdates = sourceValues?.[ONYXKEYS.COLLECTION.REPORT_VIOLATIONS] ?? {}; const transactionsUpdates = sourceValues?.[ONYXKEYS.COLLECTION.TRANSACTION]; const transactionViolationsUpdates = sourceValues?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS]; let dataToIterate = Object.keys(reports); @@ -132,7 +129,6 @@ export default createOnyxDerivedValueConfig({ ...Object.keys(reportMetadataUpdates), ...Object.keys(reportActionsUpdates), ...Object.keys(reportNameValuePairsUpdates), - ...Object.keys(reportViolationsUpdates), ...Array.from(reportUpdatesRelatedToReportActions), ]; @@ -207,7 +203,7 @@ export default createOnyxDerivedValueConfig({ }); const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`]; - const hasFieldViolations = hasVisibleReportFieldViolations(report, policy, reportViolations?.[`${ONYXKEYS.COLLECTION.REPORT_VIOLATIONS}${report.reportID}`]); + const hasFieldViolations = hasVisibleReportFieldViolations(report, policy); let brickRoadStatus; // if report has errors or violations, show red dot From 65df1a62c87cf22ce31d14b4b6341775ae57d0be Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 12 Mar 2026 10:46:30 +0700 Subject: [PATCH 11/15] prettier --- src/libs/actions/OnyxDerived/configs/reportAttributes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts index 744d85ba0b9f1..337a8cdd753b1 100644 --- a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts +++ b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts @@ -19,7 +19,7 @@ const prepareReportKeys = (keys: string[]) => { key .replace(ONYXKEYS.COLLECTION.REPORT_METADATA, ONYXKEYS.COLLECTION.REPORT) .replace(ONYXKEYS.COLLECTION.REPORT_ACTIONS, ONYXKEYS.COLLECTION.REPORT) - .replace(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, ONYXKEYS.COLLECTION.REPORT) + .replace(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, ONYXKEYS.COLLECTION.REPORT), ), ), ]; From 199a1e42d717704cc943078fc398ca074e2028e5 Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 12 Mar 2026 10:51:19 +0700 Subject: [PATCH 12/15] remove unused params --- src/libs/actions/IOU/index.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index 4f359830e46a9..05463428fb2e9 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -2534,7 +2534,6 @@ type BuildOnyxDataForTrackExpenseParams = { chat: {report: OnyxInputValue; previewAction: OnyxInputValue}; iou: {report: OnyxInputValue; createdAction: OptimisticCreatedReportAction; action: OptimisticIOUReportAction}; transactionParams: {transaction: OnyxTypes.Transaction; threadReport: OptimisticChatReport | null; threadCreatedReportAction: OptimisticCreatedReportAction | null}; - policyParams: {policy?: OnyxInputValue; tagList?: OnyxInputValue; categories?: OnyxInputValue}; shouldCreateNewMoneyRequestReport: boolean; existingTransactionThreadReportID?: string; actionableTrackExpenseWhisper?: OnyxInputValue; @@ -2558,7 +2557,6 @@ function buildOnyxDataForTrackExpense({ chat, iou, transactionParams, - policyParams = {}, shouldCreateNewMoneyRequestReport, existingTransactionThreadReportID, actionableTrackExpenseWhisper, @@ -2570,8 +2568,6 @@ function buildOnyxDataForTrackExpense({ const {report: chatReport, previewAction: reportPreviewAction} = chat; const {report: iouReport, createdAction: iouCreatedAction, action: iouAction} = iou; const {transaction, threadReport: transactionThreadReport, threadCreatedReportAction: transactionThreadCreatedReportAction} = transactionParams; - const {policy, tagList: policyTagList, categories: policyCategories} = policyParams; - const isScanRequest = isScanRequestTransactionUtils(transaction); const isDistanceRequest = isDistanceRequestTransactionUtils(transaction); const clearedPendingFields = Object.fromEntries(Object.keys(transaction.pendingFields ?? {}).map((key) => [key, null])); @@ -3933,7 +3929,6 @@ function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): T threadCreatedReportAction: optimisticCreatedActionForTransactionThread, threadReport: optimisticTransactionThread ?? {}, }, - policyParams: {policy, tagList: policyTagList, categories: policyCategories}, shouldCreateNewMoneyRequestReport, actionableTrackExpenseWhisper, retryParams, From cefbe59fe5f1ddd67f65886c77e9c9b6a3cba76d Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 12 Mar 2026 10:55:14 +0700 Subject: [PATCH 13/15] more lint --- Mobile-Expensify | 2 +- src/libs/actions/IOU/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 16295ce7472d4..3d8daef358359 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 16295ce7472d4977479b3be13b6bd7ad47b92c59 +Subproject commit 3d8daef3583592dc43bb6eb05ff46377aba2c833 diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index 05463428fb2e9..47b3295c9176f 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -3635,7 +3635,7 @@ function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): T isSelfTourViewed, } = params; const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams; - const {policy, policyCategories, policyTagList} = policyParams; + const {policy} = policyParams; const { comment, amount, From 531f260c10381c32f415c0a9d6c131612a362fa3 Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 12 Mar 2026 11:12:15 +0700 Subject: [PATCH 14/15] update tests --- tests/unit/OnyxDerivedTest.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/OnyxDerivedTest.tsx b/tests/unit/OnyxDerivedTest.tsx index 028ee038fd3ba..d12448d36d7c7 100644 --- a/tests/unit/OnyxDerivedTest.tsx +++ b/tests/unit/OnyxDerivedTest.tsx @@ -123,9 +123,9 @@ describe('OnyxDerived', () => { const transaction = createRandomTransaction(1); // When the report attributes are recomputed with both report and transaction updates - reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {}); + reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {}); const reportAttributesComputedValue = reportAttributes.compute( - [reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], + [reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], { sourceValues: { [ONYXKEYS.COLLECTION.REPORT]: { From b9e0e8879e7a8827bf7f766d62c6304d2292385b Mon Sep 17 00:00:00 2001 From: Hans Date: Fri, 13 Mar 2026 17:23:40 +0700 Subject: [PATCH 15/15] update submodule --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 3d8daef358359..59ef620a8faf6 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 3d8daef3583592dc43bb6eb05ff46377aba2c833 +Subproject commit 59ef620a8faf6bba3bfe34c9bfab9c532b073ee6