@@ -4,10 +4,15 @@ import ConnectionLayout from '@components/ConnectionLayout';
44import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription' ;
55import OfflineWithFeedback from '@components/OfflineWithFeedback' ;
66import useLocalize from '@hooks/useLocalize' ;
7+ import useOnyx from '@hooks/useOnyx' ;
8+ import usePermissions from '@hooks/usePermissions' ;
79import useThemeStyles from '@hooks/useThemeStyles' ;
10+ import useWorkspaceAccountID from '@hooks/useWorkspaceAccountID' ;
11+ import { getCardSettings } from '@libs/CardUtils' ;
812import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute' ;
913import Navigation from '@libs/Navigation/Navigation' ;
1014import { areSettingsInErrorFields , getCurrentXeroOrganizationName , settingsPendingAction } from '@libs/PolicyUtils' ;
15+ import { getIsTravelInvoicingEnabled , getTravelInvoicingCardSettingsKey } from '@libs/TravelInvoicingUtils' ;
1116import goBackFromExportConnection from '@navigation/helpers/goBackFromExportConnection' ;
1217import type { PlatformStackRouteProp } from '@navigation/PlatformStackNavigation/types' ;
1318import type { SettingsNavigatorParamList } from '@navigation/types' ;
@@ -20,19 +25,26 @@ import type SCREENS from '@src/SCREENS';
2025function XeroExportConfigurationPage ( { policy} : WithPolicyConnectionsProps ) {
2126 const { translate} = useLocalize ( ) ;
2227 const styles = useThemeStyles ( ) ;
28+ const { isBetaEnabled} = usePermissions ( ) ;
2329 const policyID = policy ?. id ;
2430 const route = useRoute < PlatformStackRouteProp < SettingsNavigatorParamList , typeof SCREENS . WORKSPACE . ACCOUNTING . XERO_EXPORT > > ( ) ;
2531 const backTo = route ?. params ?. backTo ;
2632 const policyOwner = policy ?. owner ?? '' ;
2733
28- const { export : exportConfiguration , errorFields, pendingFields} = policy ?. connections ?. xero ?. config ?? { } ;
34+ const { export : exportConfiguration , errorFields, pendingFields, travelInvoicingPayableAccountID } = policy ?. connections ?. xero ?. config ?? { } ;
2935 const shouldGoBackToSpecificRoute = ! exportConfiguration ?. nonReimbursableAccount ;
3036
3137 const goBack = useCallback ( ( ) => {
3238 return goBackFromExportConnection ( shouldGoBackToSpecificRoute , backTo ) ;
3339 } , [ backTo , shouldGoBackToSpecificRoute ] ) ;
3440
3541 const { bankAccounts} = policy ?. connections ?. xero ?. data ?? { } ;
42+ const travelPayableAccount = bankAccounts ?. find ( ( bank ) => bank . id === travelInvoicingPayableAccountID ) ;
43+ const workspaceAccountID = useWorkspaceAccountID ( policyID ) ;
44+ const [ cardSettings ] = useOnyx ( getTravelInvoicingCardSettingsKey ( workspaceAccountID ) ) ;
45+ const travelSettings = getCardSettings ( cardSettings , CONST . TRAVEL . PROGRAM_TRAVEL_US ) ;
46+ const isTravelInvoicingEnabled = isBetaEnabled ( CONST . BETAS . TRAVEL_INVOICING ) && getIsTravelInvoicingEnabled ( travelSettings ) ;
47+
3648 const selectedBankAccountName = useMemo ( ( ) => {
3749 const selectedAccount = ( bankAccounts ?? [ ] ) . find ( ( bank ) => bank . id === exportConfiguration ?. nonReimbursableAccount ) ;
3850 return selectedAccount ?. name ?? bankAccounts ?. [ 0 ] ?. name ?? '' ;
@@ -77,6 +89,16 @@ function XeroExportConfigurationPage({policy}: WithPolicyConnectionsProps) {
7789 shouldShowRightIcon : false ,
7890 helperText : translate ( 'workspace.xero.exportInvoicesDescription' ) ,
7991 } ,
92+ ...( isTravelInvoicingEnabled
93+ ? [
94+ {
95+ title : travelPayableAccount ?. name ,
96+ description : translate ( 'workspace.common.travelInvoicing' ) ,
97+ onPress : ! policyID ? undefined : ( ) => Navigation . navigate ( ROUTES . POLICY_ACCOUNTING_XERO_TRAVEL_INVOICING_CONFIGURATION . getRoute ( policyID ) ) ,
98+ subscribedSettings : [ CONST . XERO_CONFIG . TRAVEL_INVOICING_PAYABLE_ACCOUNT ] ,
99+ } ,
100+ ]
101+ : [ ] ) ,
80102 {
81103 description : translate ( 'workspace.accounting.exportCompanyCard' ) ,
82104 title : translate ( 'workspace.xero.bankTransactions' ) ,
0 commit comments