@@ -168,7 +168,7 @@ function createReportField(policyID: string, {name, type, initialValue}: CreateR
168
168
const previousFieldList = allPolicies ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` ] ?. fieldList ?? { } ;
169
169
const fieldID = WorkspaceReportFieldUtils . generateFieldID ( name ) ;
170
170
const fieldKey = ReportUtils . getReportFieldKey ( fieldID ) ;
171
- const newReportField : Omit < OnyxValueWithOfflineFeedback < PolicyReportField > , 'value' > = {
171
+ const optimisticReportFieldDataForPolicy : Omit < OnyxValueWithOfflineFeedback < PolicyReportField > , 'value' > = {
172
172
name,
173
173
type,
174
174
defaultValue : initialValue ,
@@ -182,11 +182,6 @@ function createReportField(policyID: string, {name, type, initialValue}: CreateR
182
182
isTax : false ,
183
183
} ;
184
184
185
- const optimisticReportFieldDataForPolicy : OnyxValueWithOfflineFeedback < PolicyReportField > = {
186
- ...newReportField ,
187
- value : type === CONST . REPORT_FIELD_TYPES . LIST ? CONST . REPORT_FIELD_TYPES . LIST : null ,
188
- } ;
189
-
190
185
const policyExpenseReports = Object . values ( allReports ?? { } ) . filter ( ( report ) => report ?. policyID === policyID && report . type === CONST . REPORT . TYPE . EXPENSE ) as Report [ ] ;
191
186
192
187
const optimisticData = [
@@ -205,7 +200,7 @@ function createReportField(policyID: string, {name, type, initialValue}: CreateR
205
200
onyxMethod : Onyx . METHOD . MERGE ,
206
201
value : {
207
202
fieldList : {
208
- [ fieldKey ] : { ...newReportField , pendingAction : CONST . RED_BRICK_ROAD_PENDING_ACTION . ADD } ,
203
+ [ fieldKey ] : { ...optimisticReportFieldDataForPolicy , pendingAction : CONST . RED_BRICK_ROAD_PENDING_ACTION . ADD } ,
209
204
} ,
210
205
} ,
211
206
} ) ) ,
@@ -254,7 +249,7 @@ function createReportField(policyID: string, {name, type, initialValue}: CreateR
254
249
255
250
const parameters : CreateWorkspaceReportFieldParams = {
256
251
policyID,
257
- reportFields : JSON . stringify ( [ newReportField ] ) ,
252
+ reportFields : JSON . stringify ( [ optimisticReportFieldDataForPolicy ] ) ,
258
253
} ;
259
254
260
255
API . write ( WRITE_COMMANDS . CREATE_WORKSPACE_REPORT_FIELD , parameters , onyxData ) ;
0 commit comments