@@ -6,13 +6,13 @@ import SelectionScreen from '@components/SelectionScreen';
66import Text from '@components/Text' ;
77import useLocalize from '@hooks/useLocalize' ;
88import useThemeStyles from '@hooks/useThemeStyles' ;
9- import * as Xero from '@libs/actions/connections/Xero' ;
10- import * as ErrorUtils from '@libs/ErrorUtils' ;
9+ import { updateXeroMappings } from '@libs/actions/connections/Xero' ;
10+ import { clearXeroErrorField , enablePolicyReportFields } from '@libs/actions/Policy/Policy' ;
11+ import { getLatestErrorField } from '@libs/ErrorUtils' ;
1112import Navigation from '@libs/Navigation/Navigation' ;
1213import { isControlPolicy , settingsPendingAction } from '@libs/PolicyUtils' ;
1314import type { WithPolicyProps } from '@pages/workspace/withPolicy' ;
1415import withPolicyConnections from '@pages/workspace/withPolicyConnections' ;
15- import * as Policy from '@userActions/Policy/Policy' ;
1616import CONST from '@src/CONST' ;
1717import type { TranslationPaths } from '@src/languages/types' ;
1818import ROUTES from '@src/ROUTES' ;
@@ -29,7 +29,7 @@ function XeroMapTrackingCategoryConfigurationPage({policy}: WithPolicyProps) {
2929 const styles = useThemeStyles ( ) ;
3030 const categoryId = params ?. categoryId ?? '' ;
3131 const categoryName = decodeURIComponent ( params ?. categoryName ?? '' ) ;
32- const policyID = policy ?. id ?? '-1' ;
32+ const policyID = policy ?. id ;
3333 const { config} = policy ?. connections ?. xero ?? { } ;
3434 const { trackingCategories} = policy ?. connections ?. xero ?. data ?? { } ;
3535 const { mappings} = policy ?. connections ?. xero ?. config ?? { } ;
@@ -69,16 +69,19 @@ function XeroMapTrackingCategoryConfigurationPage({policy}: WithPolicyProps) {
6969 Navigation . navigate ( `${ backToRoute } &categoryId=${ categoryId } ` ) ;
7070 return ;
7171 }
72- Xero . updateXeroMappings (
72+ if ( ! policyID ) {
73+ return ;
74+ }
75+ updateXeroMappings (
7376 policyID ,
7477 categoryId ? { [ `${ CONST . XERO_CONFIG . TRACKING_CATEGORY_PREFIX } ${ categoryId } ` ] : option . value } : { } ,
7578 categoryId ? { [ `${ CONST . XERO_CONFIG . TRACKING_CATEGORY_PREFIX } ${ categoryId } ` ] : currentTrackingCategoryValue } : { } ,
7679 ) ;
7780 if ( option . value === CONST . XERO_CONFIG . TRACKING_CATEGORY_OPTIONS . REPORT_FIELD ) {
78- Policy . enablePolicyReportFields ( policyID , true ) ;
81+ enablePolicyReportFields ( policyID , true ) ;
7982 }
8083 if ( currentTrackingCategoryValue === CONST . XERO_CONFIG . TRACKING_CATEGORY_OPTIONS . REPORT_FIELD ) {
81- Policy . enablePolicyReportFields ( policyID , false ) ;
84+ enablePolicyReportFields ( policyID , false ) ;
8285 }
8386 }
8487 Navigation . goBack ( ROUTES . POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES . getRoute ( policyID ) ) ;
@@ -101,9 +104,9 @@ function XeroMapTrackingCategoryConfigurationPage({policy}: WithPolicyProps) {
101104 headerTitleAlreadyTranslated = { translate ( 'workspace.xero.mapTrackingCategoryTo' , { categoryName} ) }
102105 connectionName = { CONST . POLICY . CONNECTIONS . NAME . XERO }
103106 pendingAction = { settingsPendingAction ( [ `${ CONST . XERO_CONFIG . TRACKING_CATEGORY_PREFIX } ${ categoryId } ` ] , config ?. pendingFields ) }
104- errors = { ErrorUtils . getLatestErrorField ( config ?? { } , `${ CONST . XERO_CONFIG . TRACKING_CATEGORY_PREFIX } ${ categoryId } ` ) }
107+ errors = { getLatestErrorField ( config ?? { } , `${ CONST . XERO_CONFIG . TRACKING_CATEGORY_PREFIX } ${ categoryId } ` ) }
105108 errorRowStyles = { [ styles . ph5 , styles . pv3 ] }
106- onClose = { ( ) => Policy . clearXeroErrorField ( policyID , `${ CONST . XERO_CONFIG . TRACKING_CATEGORY_PREFIX } ${ categoryId } ` ) }
109+ onClose = { ( ) => clearXeroErrorField ( policyID , `${ CONST . XERO_CONFIG . TRACKING_CATEGORY_PREFIX } ${ categoryId } ` ) }
107110 shouldSingleExecuteRowSelect
108111 />
109112 ) ;
0 commit comments