From c86a01b2189076f74ffaa184fec2eb0cebfe070d Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 17:02:59 -0700 Subject: [PATCH 01/14] Fix isActive for the DelaySubmissions toggle --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 372044d4bb12..ae5cc5edeb20 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -128,7 +128,7 @@ function WorkspaceWorkflowsPage({policy, betas, route}: WorkspaceWorkflowsPagePr brickRoadIndicator={hasDelayedSubmissionError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} /> ), - isActive: (policy?.harvesting?.enabled && policy.autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT && !hasDelayedSubmissionError) ?? false, + isActive: (policy?.autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT && !hasDelayedSubmissionError) ?? false, pendingAction: policy?.pendingFields?.autoReporting, errors: ErrorUtils.getLatestErrorField(policy ?? {}, CONST.POLICY.COLLECTION_KEYS.AUTOREPORTING), onCloseError: () => Policy.clearPolicyErrorField(policy?.id ?? '-1', CONST.POLICY.COLLECTION_KEYS.AUTOREPORTING), From d3fface073cb92a709e48d65b696ed533c79ae15 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 17:13:49 -0700 Subject: [PATCH 02/14] Fix display for manual frequency --- src/libs/PolicyUtils.ts | 22 +++++++++++++++++++ .../workflows/WorkspaceWorkflowsPage.tsx | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index bfce8a91e71a..03f5240a6128 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -340,6 +340,27 @@ function isInstantSubmitEnabled(policy: OnyxInputOrEntry): boolean { return policy?.type === CONST.POLICY.TYPE.FREE || (policy?.autoReporting === true && policy?.autoReportingFrequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT); } +/** + * This gets a "corrected" value for autoReportingFrequency. The purpose of this function is to encapsulate some logic around the "immediate" frequency. + * + * - "immediate" is actually not immediate. For that you want "instant". + * - immediate & harvesting.enabled === daily + * - immediate & !harvesting.enabled === manual + */ +function getCorrectedAutoReportingFrequency(policy: OnyxInputOrEntry): ValueOf | undefined { + if (policy?.autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE) { + return policy?.autoReportingFrequency; + } + + if (policy?.harvesting?.enabled) { + // this is actually not really "immediate". It's "daily". Surprise! + return CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE; + } + + // "manual" is really just "daily" with harvesting disabled + return CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL; +} + /** * Checks if policy's approval mode is "optional", a.k.a. "Submit & Close" */ @@ -793,6 +814,7 @@ export { isDeletedPolicyEmployee, isFreeGroupPolicy, isInstantSubmitEnabled, + getCorrectedAutoReportingFrequency, isPaidGroupPolicy, isPendingDeletePolicy, isPolicyAdmin, diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index ae5cc5edeb20..11c2d370fc3d 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -119,7 +119,7 @@ function WorkspaceWorkflowsPage({policy, betas, route}: WorkspaceWorkflowsPagePr // Instant submit is the equivalent of delayed submissions being turned off, so we show the feature as disabled if the frequency is instant description={ getAutoReportingFrequencyDisplayNames(preferredLocale)[ - (policy?.autoReportingFrequency as AutoReportingFrequencyKey) ?? CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY + (PolicyUtils.getCorrectedAutoReportingFrequency(policy) as AutoReportingFrequencyKey) ?? CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY ] } shouldShowRightIcon From 9b40a16310bb0b222f38f5ee1ab74af54ada8604 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 17:16:56 -0700 Subject: [PATCH 03/14] Improve comment --- src/libs/PolicyUtils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 03f5240a6128..f57a11203464 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -346,6 +346,8 @@ function isInstantSubmitEnabled(policy: OnyxInputOrEntry): boolean { * - "immediate" is actually not immediate. For that you want "instant". * - immediate & harvesting.enabled === daily * - immediate & !harvesting.enabled === manual + * + * Note that "daily" and "manual" only exist as options for the API, not in the database or Onyx. */ function getCorrectedAutoReportingFrequency(policy: OnyxInputOrEntry): ValueOf | undefined { if (policy?.autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE) { From 883e672fe95fc1fe612505481264b79ba3dc1830 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 18:40:36 -0700 Subject: [PATCH 04/14] Fix display issue in list --- .../workspace/workflows/WorkspaceAutoReportingFrequencyPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage.tsx b/src/pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage.tsx index 6f6e5fcff15d..c253ca7a4806 100644 --- a/src/pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage.tsx @@ -98,7 +98,7 @@ function WorkspaceAutoReportingFrequencyPage({policy, route}: WorkspaceAutoRepor ); const autoReportingFrequencyItems: WorkspaceAutoReportingFrequencyPageItem[] = Object.keys(getAutoReportingFrequencyDisplayNames(preferredLocale)).map((frequencyKey) => { - const isSelected = policy?.autoReportingFrequency === frequencyKey; + const isSelected = PolicyUtils.getCorrectedAutoReportingFrequency(policy) === frequencyKey; return { text: getAutoReportingFrequencyDisplayNames(preferredLocale)[frequencyKey as AutoReportingFrequencyKey] || '', From 4f737844e20be2d0c3ff5d1cf660d02a2cb07342 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 18:47:48 -0700 Subject: [PATCH 05/14] Fix autoReportingFrequency in setWorkspaceAutoReportingFrequency --- src/libs/NextStepUtils.ts | 3 ++- src/libs/actions/Policy/Policy.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 0ac2878b6857..59f46b429698 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -79,7 +79,8 @@ function buildNextStep(report: OnyxEntry, predictedNextStatus: ValueOf Date: Tue, 16 Jul 2024 18:49:29 -0700 Subject: [PATCH 06/14] Fix upgradeToCorporate --- src/libs/actions/Policy/Policy.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 916bf483ecae..f96a38db2000 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -3047,8 +3047,11 @@ function upgradeToCorporate(policyID: string, featureName: string) { glCodes: true, ...(PolicyUtils.isInstantSubmitEnabled(policy) && { autoReporting: true, - autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL, + autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE, }), + harvesting: { + enabled: false, + }, }, }, ]; @@ -3076,6 +3079,7 @@ function upgradeToCorporate(policyID: string, featureName: string) { glCodes: policy?.glCodes ?? null, autoReporting: policy?.autoReporting ?? null, autoReportingFrequency: policy?.autoReportingFrequency ?? null, + harvesting: policy?.harvesting ?? null, }, }, ]; From d49ad9ad8f6ed612fd63bc3da423d283403229c8 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 18:57:23 -0700 Subject: [PATCH 07/14] Account for harvesting in setWorkspaceAutoReportingFrequency optimistic data --- src/libs/actions/Policy/Policy.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index f96a38db2000..8210134e0a41 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -350,6 +350,11 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf // Recall that the "daily" and "manual" frequencies don't actually exist in Onyx or the DB (see PolicyUtils.getCorrectedAutoReportingFrequency) autoReportingFrequency: frequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL ? CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE : frequency, pendingFields: {autoReportingFrequency: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, + ...(frequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL && { + harvesting: { + enabled: false, + }, + }), }, }, ]; @@ -360,6 +365,7 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { autoReportingFrequency: policy?.autoReportingFrequency ?? null, + harvesting: policy?.harvesting ?? null, pendingFields: {autoReportingFrequency: null}, errorFields: {autoReportingFrequency: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workflowsDelayedSubmissionPage.autoReportingFrequencyErrorMessage')}, }, From 8b115726a757b64a92de18412ca7c9d24ec9eee5 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 19:01:06 -0700 Subject: [PATCH 08/14] Fix initial focus --- .../WorkspaceAutoReportingFrequencyPage.tsx | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage.tsx b/src/pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage.tsx index c253ca7a4806..704f1def7ad3 100644 --- a/src/pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage.tsx @@ -48,9 +48,11 @@ const getAutoReportingFrequencyDisplayNames = (locale: Locale): AutoReportingFre }); function WorkspaceAutoReportingFrequencyPage({policy, route}: WorkspaceAutoReportingFrequencyPageProps) { + const autoReportingFrequency = PolicyUtils.getCorrectedAutoReportingFrequency(policy); + const {translate, preferredLocale, toLocaleOrdinal} = useLocalize(); const styles = useThemeStyles(); - const [isMonthlyFrequency, setIsMonthlyFrequency] = useState(policy?.autoReportingFrequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY); + const [isMonthlyFrequency, setIsMonthlyFrequency] = useState(autoReportingFrequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY); const onSelectAutoReportingFrequency = (item: WorkspaceAutoReportingFrequencyPageItem) => { Policy.setWorkspaceAutoReportingFrequency(policy?.id ?? '-1', item.keyForList as AutoReportingFrequencyKey); @@ -97,16 +99,12 @@ function WorkspaceAutoReportingFrequencyPage({policy, route}: WorkspaceAutoRepor ); - const autoReportingFrequencyItems: WorkspaceAutoReportingFrequencyPageItem[] = Object.keys(getAutoReportingFrequencyDisplayNames(preferredLocale)).map((frequencyKey) => { - const isSelected = PolicyUtils.getCorrectedAutoReportingFrequency(policy) === frequencyKey; - - return { - text: getAutoReportingFrequencyDisplayNames(preferredLocale)[frequencyKey as AutoReportingFrequencyKey] || '', - keyForList: frequencyKey, - isSelected, - footerContent: isMonthlyFrequency && frequencyKey === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY ? monthlyFrequencyDetails() : null, - }; - }); + const autoReportingFrequencyItems: WorkspaceAutoReportingFrequencyPageItem[] = Object.keys(getAutoReportingFrequencyDisplayNames(preferredLocale)).map((frequencyKey) => ({ + text: getAutoReportingFrequencyDisplayNames(preferredLocale)[frequencyKey as AutoReportingFrequencyKey] || '', + keyForList: frequencyKey, + isSelected: frequencyKey === autoReportingFrequency, + footerContent: isMonthlyFrequency && frequencyKey === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY ? monthlyFrequencyDetails() : null, + })); return ( From c9143de446641c546f4b37d147027bfccab87c28 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 19:04:42 -0700 Subject: [PATCH 09/14] clarify comment --- src/libs/PolicyUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index f57a11203464..17ad47c00313 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -344,8 +344,8 @@ function isInstantSubmitEnabled(policy: OnyxInputOrEntry): boolean { * This gets a "corrected" value for autoReportingFrequency. The purpose of this function is to encapsulate some logic around the "immediate" frequency. * * - "immediate" is actually not immediate. For that you want "instant". - * - immediate & harvesting.enabled === daily - * - immediate & !harvesting.enabled === manual + * - (immediate && harvesting.enabled) === daily + * - (immediate && !harvesting.enabled) === manual * * Note that "daily" and "manual" only exist as options for the API, not in the database or Onyx. */ From 4aa4ea883ec7dd06bf6af019af2ccdd227ed359f Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 19:05:52 -0700 Subject: [PATCH 10/14] clarify another comment --- src/libs/PolicyUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 17ad47c00313..f0eed5375658 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -359,7 +359,7 @@ function getCorrectedAutoReportingFrequency(policy: OnyxInputOrEntry): V return CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE; } - // "manual" is really just "daily" with harvesting disabled + // "manual" is really just "immediate" (aka "daily") with harvesting disabled return CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL; } From f5b529e74d6072ce7af3229f01a88d3291f1c8db Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 23:06:51 -0700 Subject: [PATCH 11/14] Re-enable harvesting if manual reporting is changed to auto reporting --- src/libs/actions/Policy/Policy.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 8210134e0a41..abb4f0b204c3 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -342,6 +342,8 @@ function deleteWorkspace(policyID: string, policyName: string) { function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf) { const policy = getPolicy(policyID); + const wasPolicyManuallyReported = PolicyUtils.getCorrectedAutoReportingFrequency(policy) === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL; + const optimisticData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, @@ -355,6 +357,12 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf enabled: false, }, }), + ...(wasPolicyManuallyReported && + frequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL && { + harvesting: { + enabled: true, + }, + }), }, }, ]; From ac5770e92541b19e9b30c99ef37546c0fc3a8954 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 23:24:14 -0700 Subject: [PATCH 12/14] Use types to prevent manual from being saved in Onyx --- src/types/onyx/Policy.ts | 8 ++++++-- tests/unit/NextStepUtilsTest.ts | 4 ++-- tests/utils/collections/policies.ts | 8 +++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index ed10473ecb97..c6ee689fe131 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1352,8 +1352,12 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** Whether the auto reporting is enabled */ autoReporting?: boolean; - /** The scheduled submit frequency set up on this policy */ - autoReportingFrequency?: ValueOf; + /** + * The scheduled submit frequency set up on this policy. + * Note that manual does not exist in the DB and thus should not exist in Onyx, only as a param for the API. + * "manual" really means "immediate" (aka "daily") && harvesting.enabled === false + */ + autoReportingFrequency?: Exclude, typeof CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL>; /** Scheduled submit data */ harvesting?: { diff --git a/tests/unit/NextStepUtilsTest.ts b/tests/unit/NextStepUtilsTest.ts index f92bc7a9dfee..fce66fbb1249 100644 --- a/tests/unit/NextStepUtilsTest.ts +++ b/tests/unit/NextStepUtilsTest.ts @@ -311,9 +311,9 @@ describe('libs/NextStepUtils', () => { ]; return Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { - autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL, + autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE, harvesting: { - enabled: true, + enabled: false, }, }).then(() => { const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.OPEN); diff --git a/tests/utils/collections/policies.ts b/tests/utils/collections/policies.ts index d34a2f6474b5..47bf996afb7e 100644 --- a/tests/utils/collections/policies.ts +++ b/tests/utils/collections/policies.ts @@ -1,4 +1,5 @@ import {rand, randAvatar, randBoolean, randCurrencyCode, randEmail, randPastDate, randWord} from '@ngneat/falso'; +import type {ValueOf} from 'type-fest'; import CONST from '@src/CONST'; import type {Policy} from '@src/types/onyx'; @@ -9,7 +10,12 @@ export default function createRandomPolicy(index: number): Policy { type: rand(Object.values(CONST.POLICY.TYPE)), autoReporting: randBoolean(), isPolicyExpenseChatEnabled: randBoolean(), - autoReportingFrequency: rand(Object.values(CONST.POLICY.AUTO_REPORTING_FREQUENCIES)), + autoReportingFrequency: rand( + Object.values(CONST.POLICY.AUTO_REPORTING_FREQUENCIES).filter( + (frequency): frequency is Exclude, typeof CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL> => + frequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL, + ), + ), harvesting: { enabled: randBoolean(), }, From 11e86eda68eb85e5a9c38a0ece352f08a69e233e Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 16 Jul 2024 23:27:21 -0700 Subject: [PATCH 13/14] Improve comments --- src/libs/actions/Policy/Policy.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index abb4f0b204c3..996c196ac9d3 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -352,11 +352,16 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf // Recall that the "daily" and "manual" frequencies don't actually exist in Onyx or the DB (see PolicyUtils.getCorrectedAutoReportingFrequency) autoReportingFrequency: frequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL ? CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE : frequency, pendingFields: {autoReportingFrequency: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, + + // To set the frequency to "manual", we really must set it to "immediate" with harvesting disabled ...(frequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL && { harvesting: { enabled: false, }, }), + + // If the policy was manually reported before, and now will be auto-reported, + // then we must re-enable harvesting ...(wasPolicyManuallyReported && frequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL && { harvesting: { From ad6cbeb1db4826ca5f82b36e89e7f4032d26e6fd Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 17 Jul 2024 09:53:58 -0700 Subject: [PATCH 14/14] comment and variable name improvement --- src/libs/PolicyUtils.ts | 2 +- src/libs/actions/Policy/Policy.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index f0eed5375658..fe53a7bcd5ce 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -355,7 +355,7 @@ function getCorrectedAutoReportingFrequency(policy: OnyxInputOrEntry): V } if (policy?.harvesting?.enabled) { - // this is actually not really "immediate". It's "daily". Surprise! + // This is actually not really "immediate". It's "daily". Surprise! return CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE; } diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 996c196ac9d3..7ea6e9b8b74a 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -342,7 +342,7 @@ function deleteWorkspace(policyID: string, policyName: string) { function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf) { const policy = getPolicy(policyID); - const wasPolicyManuallyReported = PolicyUtils.getCorrectedAutoReportingFrequency(policy) === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL; + const wasPolicyOnManualReporting = PolicyUtils.getCorrectedAutoReportingFrequency(policy) === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL; const optimisticData: OnyxUpdate[] = [ { @@ -360,9 +360,9 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf }, }), - // If the policy was manually reported before, and now will be auto-reported, + // If the policy was on manual reporting before, and now will be auto-reported, // then we must re-enable harvesting - ...(wasPolicyManuallyReported && + ...(wasPolicyOnManualReporting && frequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL && { harvesting: { enabled: true,