diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index e237ed80e29..a623989cfb6 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -846,7 +846,7 @@ function deleteWorkspaceCategories(policyID: string, categoryNamesToDelete: stri const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]; const policyCategories = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`] ?? {}; const optimisticPolicyCategoriesData = categoryNamesToDelete.reduce>>((acc, categoryName) => { - acc[categoryName] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}; + acc[categoryName] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, enabled: false}; return acc; }, {}); const shouldDisableRequiresCategory = !OptionsListUtils.hasEnabledOptions( @@ -878,6 +878,7 @@ function deleteWorkspaceCategories(policyID: string, categoryNamesToDelete: stri acc[categoryName] = { pendingAction: null, errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.categories.deleteFailureMessage'), + enabled: !!policyCategories?.[categoryName]?.enabled, }; return acc; }, {}), diff --git a/src/libs/actions/Policy/Tag.ts b/src/libs/actions/Policy/Tag.ts index 2a3080fc810..7708921f57b 100644 --- a/src/libs/actions/Policy/Tag.ts +++ b/src/libs/actions/Policy/Tag.ts @@ -356,7 +356,7 @@ function deletePolicyTags(policyID: string, tagsToDelete: string[]) { [policyTag.name]: { tags: { ...tagsToDelete.reduce>>>((acc, tagName) => { - acc[tagName] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}; + acc[tagName] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, enabled: false}; return acc; }, {}), }, @@ -388,7 +388,11 @@ function deletePolicyTags(policyID: string, tagsToDelete: string[]) { [policyTag.name]: { tags: { ...tagsToDelete.reduce>>>((acc, tagName) => { - acc[tagName] = {pendingAction: null, errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.tags.deleteFailureMessage')}; + acc[tagName] = { + pendingAction: null, + errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.tags.deleteFailureMessage'), + enabled: !!policyTag?.tags[tagName]?.enabled, + }; return acc; }, {}), }, diff --git a/src/libs/actions/TaxRate.ts b/src/libs/actions/TaxRate.ts index abe2f68d2a8..52a8b8e143b 100644 --- a/src/libs/actions/TaxRate.ts +++ b/src/libs/actions/TaxRate.ts @@ -275,7 +275,7 @@ function setPolicyTaxesEnabled(policyID: string, taxesIDsToUpdate: string[], isE type TaxRateDeleteMap = Record< string, - | (Pick & { + | (Pick & { errors: OnyxCommon.Errors | null; }) | null @@ -306,7 +306,7 @@ function deletePolicyTaxes(policyID: string, taxesToDelete: string[]) { pendingFields: {foreignTaxDefault: isForeignTaxRemoved ? CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE : null}, foreignTaxDefault: isForeignTaxRemoved ? firstTaxID : foreignTaxDefault, taxes: taxesToDelete.reduce((acc, taxID) => { - acc[taxID] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, errors: null}; + acc[taxID] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, errors: null, isDisabled: true}; return acc; }, {}), }, @@ -339,6 +339,7 @@ function deletePolicyTaxes(policyID: string, taxesToDelete: string[]) { acc[taxID] = { pendingAction: null, errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.taxes.error.deleteFailureMessage'), + isDisabled: !!policyTaxRates?.[taxID]?.isDisabled, }; return acc; }, {}),