diff --git a/src/libs/actions/Policy/Tag.ts b/src/libs/actions/Policy/Tag.ts index a4e0af63512b..7d3c32c73d9e 100644 --- a/src/libs/actions/Policy/Tag.ts +++ b/src/libs/actions/Policy/Tag.ts @@ -471,6 +471,27 @@ function enablePolicyTags(policyID: string, enabled: boolean) { }, ], }; + const policyTagList = allPolicyTags?.[policyID]; + if (!policyTagList) { + const defaultTagList: PolicyTagList = { + Tag: { + name: 'Tag', + orderWeight: 0, + required: false, + tags: {}, + }, + }; + onyxData.optimisticData?.push({ + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, + value: defaultTagList, + }); + onyxData.failureData?.push({ + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, + value: null, + }); + } const parameters: EnablePolicyTagsParams = {policyID, enabled};