From 16cc37f2cfb7f6cc6d4fc0335f6dc05f151735d5 Mon Sep 17 00:00:00 2001 From: Chirag Chandrakant Salian Date: Wed, 28 Aug 2024 09:57:35 -0700 Subject: [PATCH] Merge pull request #48109 from cretadn22/handle-same-value-submit [CP Staging] Update submit function in initial report field value (cherry picked from commit 5368e47e7e4a135a66e28a10a89c328664842172) (CP triggered by chiragsalian) --- .../reportFields/ReportFieldsInitialValuePage.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx b/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx index d2f7a5e69eea..74ed854a0495 100644 --- a/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx +++ b/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx @@ -43,19 +43,21 @@ function ReportFieldsInitialValuePage({ const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy); const reportField = policy?.fieldList?.[ReportUtils.getReportFieldKey(reportFieldID)] ?? null; const availableListValuesLength = (reportField?.disabledOptions ?? []).filter((disabledListValue) => !disabledListValue).length; - - const [initialValue, setInitialValue] = useState(WorkspaceReportFieldUtils.getReportFieldInitialValue(reportField)); + const currentInitialValue = WorkspaceReportFieldUtils.getReportFieldInitialValue(reportField); + const [initialValue, setInitialValue] = useState(currentInitialValue); const submitForm = useCallback( (values: FormOnyxValues) => { - ReportField.updateReportFieldInitialValue(policyID, reportFieldID, initialValue === values.initialValue ? '' : values.initialValue); + if (currentInitialValue !== values.initialValue) { + ReportField.updateReportFieldInitialValue(policyID, reportFieldID, values.initialValue); + } Navigation.goBack(); }, - [policyID, reportFieldID, initialValue], + [policyID, reportFieldID, currentInitialValue], ); const submitListValueUpdate = (value: string) => { - ReportField.updateReportFieldInitialValue(policyID, reportFieldID, initialValue === value ? '' : value); + ReportField.updateReportFieldInitialValue(policyID, reportFieldID, currentInitialValue === value ? '' : value); Navigation.goBack(); };