@@ -18,8 +18,8 @@ import useLocalize from '@hooks/useLocalize';
1818import useOnyx from '@hooks/useOnyx' ;
1919import usePolicy from '@hooks/usePolicy' ;
2020import useThemeStyles from '@hooks/useThemeStyles' ;
21- import { deleteWorkspaceCompanyCardFeed , setWorkspaceCompanyCardTransactionLiability } from '@libs/actions/CompanyCards' ;
22- import { getCompanyCardFeed , getCompanyFeeds , getCustomOrFormattedFeedName , getDomainOrWorkspaceAccountID , getSelectedFeed , isDirectFeed } from '@libs/CardUtils' ;
21+ import { deleteWorkspaceCompanyCardFeed , setAddNewCompanyCardStepAndData , setWorkspaceCompanyCardTransactionLiability } from '@libs/actions/CompanyCards' ;
22+ import { getCompanyCardFeed , getCompanyFeeds , getCustomOrFormattedFeedName , getDomainOrWorkspaceAccountID , getSelectedFeed , isCSVUploadFeed , isDirectFeed } from '@libs/CardUtils' ;
2323import Navigation from '@libs/Navigation/Navigation' ;
2424import type { PlatformStackScreenProps } from '@libs/Navigation/PlatformStackNavigation/types' ;
2525import type { SettingsNavigatorParamList } from '@libs/Navigation/types' ;
@@ -32,6 +32,15 @@ import ROUTES from '@src/ROUTES';
3232import type SCREENS from '@src/SCREENS' ;
3333import type { CompanyCardFeedWithDomainID } from '@src/types/onyx' ;
3434
35+ const ADVANCED_CSV_COLUMNS = new Set < string > ( [
36+ CONST . CSV_IMPORT_COLUMNS . ORIGINAL_TRANSACTION_DATE ,
37+ CONST . CSV_IMPORT_COLUMNS . ORIGINAL_AMOUNT ,
38+ CONST . CSV_IMPORT_COLUMNS . ORIGINAL_CURRENCY ,
39+ CONST . CSV_IMPORT_COLUMNS . COMMENT ,
40+ CONST . CSV_IMPORT_COLUMNS . CATEGORY ,
41+ CONST . CSV_IMPORT_COLUMNS . TAG ,
42+ ] ) ;
43+
3544type WorkspaceCompanyCardsSettingsPageProps = PlatformStackScreenProps < SettingsNavigatorParamList , typeof SCREENS . WORKSPACE . COMPANY_CARDS_SETTINGS > ;
3645
3746function WorkspaceCompanyCardsSettingsPage ( {
@@ -55,7 +64,7 @@ function WorkspaceCompanyCardsSettingsPage({
5564 const { showConfirmModal} = useConfirmModal ( ) ;
5665
5766 const [ cardsList ] = useCardsList ( selectedFeed ) ;
58- const icons = useMemoizedLazyExpensifyIcons ( [ 'Sync' , 'Trashcan' ] ) ;
67+ const icons = useMemoizedLazyExpensifyIcons ( [ 'Sync' , 'Trashcan' , 'Table' ] ) ;
5968 const feedName = selectedFeed ? getCustomOrFormattedFeedName ( translate , feed , cardFeeds ?. [ selectedFeed ] ?. customFeedName ) : undefined ;
6069 const companyFeeds = getCompanyFeeds ( cardFeeds ) ;
6170 const selectedFeedData = selectedFeed ? companyFeeds [ selectedFeed ] : undefined ;
@@ -64,6 +73,10 @@ function WorkspaceCompanyCardsSettingsPage({
6473 const domainOrWorkspaceAccountID = getDomainOrWorkspaceAccountID ( workspaceAccountID , selectedFeedData ) ;
6574 const isPending = ! ! selectedFeedData ?. pending ;
6675 const isDirectFeedType = isDirectFeed ( feed ) ;
76+ const isCsvFeed = isCSVUploadFeed ( feed ) ;
77+ const storedMappings = selectedFeedData ?. uploadLayoutSettings ?. columnMappings ;
78+ const hadAdvancedFields = ! ! storedMappings && Object . keys ( storedMappings ) . some ( ( col ) => ADVANCED_CSV_COLUMNS . has ( col ) ) ;
79+
6780 const statementCloseDate = useMemo ( ( ) => {
6881 if ( ! selectedFeedData ?. statementPeriodEndDay ) {
6982 return undefined ;
@@ -173,6 +186,23 @@ function WorkspaceCompanyCardsSettingsPage({
173186 } }
174187 />
175188 ) }
189+ { isCsvFeed && (
190+ < MenuItem
191+ icon = { icons . Table }
192+ title = { translate ( 'spreadsheet.importSpreadsheet' ) }
193+ onPress = { ( ) => {
194+ setAddNewCompanyCardStepAndData ( {
195+ data : {
196+ layoutType : feed ,
197+ companyCardLayoutName : selectedFeedData ?. customFeedName ?? feedName ?? '' ,
198+ useAdvancedFields : hadAdvancedFields ,
199+ existingInstanceID : selectedFeedData ?. uploadLayoutSettings ?. instanceID ?? null ,
200+ } ,
201+ } ) ;
202+ Navigation . navigate ( ROUTES . WORKSPACE_COMPANY_CARDS_IMPORT_SPREADSHEET . getRoute ( policyID ) ) ;
203+ } }
204+ />
205+ ) }
176206 < MenuItem
177207 icon = { icons . Trashcan }
178208 title = { translate ( 'workspace.moreFeatures.companyCards.removeCardFeed' ) }
0 commit comments