-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[NO QA] Remove ONYXKEYS.COLLECTION.REPORT_VIOLATIONS #84673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b59bcf3
0a77e48
d530238
bf5b4c4
82fca27
55210cc
8b0d2c9
aff39a0
341a915
5617fa0
96afadc
53eba9d
65df1a6
199a1e4
cefbe59
531f260
1894a40
4fca833
b2c1058
c861c89
b9e0e88
d6ccf08
0f9e49a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,7 +79,6 @@ import { | |
| getSubmitToAccountID, | ||
| hasDependentTags, | ||
| hasDynamicExternalWorkflow, | ||
| isControlPolicy, | ||
| isDelayedSubmissionEnabled, | ||
| isPaidGroupPolicy, | ||
| isPolicyAdmin, | ||
|
|
@@ -1781,39 +1780,6 @@ function getReceiptError( | |
| ); | ||
| } | ||
|
|
||
| /** Helper function to get optimistic fields violations onyx data */ | ||
| function getFieldViolationsOnyxData(iouReport: OnyxTypes.Report): OnyxData<typeof ONYXKEYS.COLLECTION.REPORT_VIOLATIONS> { | ||
| 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']; | ||
|
|
@@ -2584,7 +2550,6 @@ type BuildOnyxDataForTrackExpenseParams = { | |
| chat: {report: OnyxInputValue<OnyxTypes.Report>; previewAction: OnyxInputValue<ReportAction>}; | ||
| iou: {report: OnyxInputValue<OnyxTypes.Report>; createdAction: OptimisticCreatedReportAction; action: OptimisticIOUReportAction}; | ||
| transactionParams: {transaction: OnyxTypes.Transaction; threadReport: OptimisticChatReport | null; threadCreatedReportAction: OptimisticCreatedReportAction | null}; | ||
| policyParams: {policy?: OnyxInputValue<OnyxTypes.Policy>; tagList?: OnyxInputValue<OnyxTypes.PolicyTagLists>; categories?: OnyxInputValue<OnyxTypes.PolicyCategories>}; | ||
| shouldCreateNewMoneyRequestReport: boolean; | ||
| existingTransactionThreadReportID?: string; | ||
| actionableTrackExpenseWhisper?: OnyxInputValue<OnyxTypes.ReportAction>; | ||
|
|
@@ -2601,15 +2566,13 @@ 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({ | ||
| chat, | ||
| iou, | ||
| transactionParams, | ||
| policyParams = {}, | ||
| shouldCreateNewMoneyRequestReport, | ||
| existingTransactionThreadReportID, | ||
| actionableTrackExpenseWhisper, | ||
|
|
@@ -2621,8 +2584,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])); | ||
|
|
@@ -2998,38 +2959,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, | ||
| ); | ||
Julesssss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (violationsOnyxData) { | ||
| onyxData.optimisticData?.push(violationsOnyxData); | ||
| onyxData.failureData?.push({ | ||
| onyxMethod: Onyx.METHOD.SET, | ||
| key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`, | ||
| value: [], | ||
| }); | ||
| } | ||
|
|
||
| // 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 ?? [])); | ||
| } | ||
|
|
||
|
Comment on lines
-3026
to
-3032
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hungvu193 It is only safe to remove this if the condition in line 3095 is always true So violationsOnyxData also should be removed if we removed this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please help to confirm this one before removing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This condition: transaction.reportID === CONST.REPORT.UNREPORTED_REPORT_IDis always true for track expense so it's safe to remove it. I'll remove the rest condition as well
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hungvu193 Please ping me when it's done. Thanks |
||
| return onyxData; | ||
| } | ||
|
|
||
|
|
@@ -3722,7 +3651,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, | ||
|
|
@@ -4017,7 +3946,6 @@ function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): T | |
| threadCreatedReportAction: optimisticCreatedActionForTransactionThread, | ||
| threadReport: optimisticTransactionThread ?? {}, | ||
| }, | ||
| policyParams: {policy, tagList: policyTagList, categories: policyCategories}, | ||
| shouldCreateNewMoneyRequestReport, | ||
| actionableTrackExpenseWhisper, | ||
| retryParams, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.