diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index eb190d9b1e67..b04536915b6c 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -1466,6 +1466,11 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol harvesting: { enabled: true, }, + pendingFields: { + autoReporting: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + approvalMode: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + reimbursementChoice: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + }, }, }, ]; @@ -1538,6 +1543,11 @@ function buildPolicyData(policyOwnerEmail = '', makeMeAdmin = false, policyName }, }, chatReportIDAdmins: makeMeAdmin ? Number(adminsChatReportID) : undefined, + pendingFields: { + autoReporting: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + approvalMode: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + reimbursementChoice: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + }, }, }, { @@ -1606,7 +1616,14 @@ function buildPolicyData(policyOwnerEmail = '', makeMeAdmin = false, policyName { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: {pendingAction: null}, + value: { + pendingAction: null, + pendingFields: { + autoReporting: null, + approvalMode: null, + reimbursementChoice: null, + }, + }, }, { onyxMethod: Onyx.METHOD.MERGE, @@ -1802,6 +1819,11 @@ function createDraftWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policy }, }, chatReportIDAdmins: makeMeAdmin ? Number(adminsChatReportID) : undefined, + pendingFields: { + autoReporting: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + approvalMode: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + reimbursementChoice: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + }, }, }, { @@ -2078,6 +2100,11 @@ function createWorkspaceFromIOUPayment(iouReport: Report | EmptyObject): string errors: {}, }, }, + pendingFields: { + autoReporting: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + approvalMode: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + reimbursementChoice: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, + }, }; const optimisticData: OnyxUpdate[] = [ @@ -2148,7 +2175,14 @@ function createWorkspaceFromIOUPayment(iouReport: Report | EmptyObject): string { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: {pendingAction: null}, + value: { + pendingAction: null, + pendingFields: { + autoReporting: null, + approvalMode: null, + reimbursementChoice: null, + }, + }, }, { onyxMethod: Onyx.METHOD.MERGE, diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx index da5fbb777306..8764ff70cc28 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx @@ -110,11 +110,16 @@ function PolicyDistanceRatesPage({policy, route}: PolicyDistanceRatesPageProps) keyForList: value.customUnitRateID ?? '', isSelected: selectedDistanceRates.find((rate) => rate.customUnitRateID === value.customUnitRateID) !== undefined, isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, - pendingAction: value.pendingAction ?? value.pendingFields?.rate ?? value.pendingFields?.enabled ?? value.pendingFields?.currency, + pendingAction: + value.pendingAction ?? + value.pendingFields?.rate ?? + value.pendingFields?.enabled ?? + value.pendingFields?.currency ?? + (policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD ? policy?.pendingAction : undefined), errors: value.errors ?? undefined, rightElement: , })), - [customUnit?.attributes?.unit, customUnitRates, selectedDistanceRates, translate], + [customUnit?.attributes?.unit, customUnitRates, selectedDistanceRates, translate, policy?.pendingAction], ); const addRate = () => {