@@ -152,6 +152,7 @@ type BuildPolicyDataOptions = {
152152 shouldAddOnboardingTasks ?: boolean ;
153153 companySize ?: OnboardingCompanySize ;
154154 userReportedIntegration ?: OnboardingAccounting ;
155+ isAnnualSubscription ?: boolean ;
155156} ;
156157
157158const allPolicies : OnyxCollection < Policy > = { } ;
@@ -1803,8 +1804,9 @@ function buildOptimisticDistanceRateCustomUnits(reportCurrency?: string): Optimi
18031804 * @param [makeMeAdmin] leave the calling account as an admin on the policy
18041805 * @param [currency] Optional, selected currency for the workspace
18051806 * @param [file], avatar file for workspace
1807+ * @param [isAnnualSubscription] Optional, does user have an annual subscription
18061808 */
1807- function createDraftInitialWorkspace ( policyOwnerEmail = '' , policyName = '' , policyID = generatePolicyID ( ) , makeMeAdmin = false , currency = '' , file ?: File ) {
1809+ function createDraftInitialWorkspace ( policyOwnerEmail = '' , policyName = '' , policyID = generatePolicyID ( ) , makeMeAdmin = false , currency = '' , file ?: File , isAnnualSubscription = false ) {
18081810 const workspaceName = policyName || generateDefaultWorkspaceName ( policyOwnerEmail ) ;
18091811 const { customUnits, outputCurrency} = buildOptimisticDistanceRateCustomUnits ( currency ) ;
18101812 const shouldEnableWorkflowsByDefault =
@@ -1816,15 +1818,15 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol
18161818 key : `${ ONYXKEYS . COLLECTION . POLICY_DRAFTS } ${ policyID } ` ,
18171819 value : {
18181820 id : policyID ,
1819- type : CONST . POLICY . TYPE . TEAM ,
1821+ type : isAnnualSubscription ? CONST . POLICY . TYPE . CORPORATE : CONST . POLICY . TYPE . TEAM ,
18201822 name : workspaceName ,
18211823 role : CONST . POLICY . ROLE . ADMIN ,
18221824 owner : sessionEmail ,
18231825 ownerAccountID : sessionAccountID ,
18241826 isPolicyExpenseChatEnabled : true ,
18251827 areCategoriesEnabled : true ,
18261828 approver : sessionEmail ,
1827- areCompanyCardsEnabled : true ,
1829+ areCompanyCardsEnabled : ! isAnnualSubscription ,
18281830 areExpensifyCardsEnabled : false ,
18291831 outputCurrency,
18301832 pendingAction : CONST . RED_BRICK_ROAD_PENDING_ACTION . ADD ,
@@ -1888,6 +1890,7 @@ function buildPolicyData(options: BuildPolicyDataOptions = {}) {
18881890 shouldAddOnboardingTasks = true ,
18891891 companySize,
18901892 userReportedIntegration,
1893+ isAnnualSubscription = false ,
18911894 } = options ;
18921895 const workspaceName = policyName || generateDefaultWorkspaceName ( policyOwnerEmail ) ;
18931896
@@ -1918,7 +1921,9 @@ function buildPolicyData(options: BuildPolicyDataOptions = {}) {
19181921
19191922 // Determine workspace type based on user reported integration
19201923 const workspaceType =
1921- userReportedIntegration && ( CONST . POLICY . CONNECTIONS . CORPORATE as readonly string [ ] ) . includes ( userReportedIntegration ) ? CONST . POLICY . TYPE . CORPORATE : CONST . POLICY . TYPE . TEAM ;
1924+ ( ! ! userReportedIntegration && ( CONST . POLICY . CONNECTIONS . CORPORATE as readonly string [ ] ) . includes ( userReportedIntegration ) ) || isAnnualSubscription
1925+ ? CONST . POLICY . TYPE . CORPORATE
1926+ : CONST . POLICY . TYPE . TEAM ;
19221927
19231928 // WARNING: The data below should be kept in sync with the API so we create the policy with the correct configuration.
19241929 const optimisticData : OnyxUpdate [ ] = [
@@ -1945,7 +1950,7 @@ function buildPolicyData(options: BuildPolicyDataOptions = {}) {
19451950 } ,
19461951 customUnits,
19471952 areCategoriesEnabled : true ,
1948- areCompanyCardsEnabled : true ,
1953+ areCompanyCardsEnabled : workspaceType === CONST . POLICY . TYPE . TEAM ,
19491954 areTagsEnabled : false ,
19501955 areDistanceRatesEnabled : false ,
19511956 areWorkflowsEnabled : shouldEnableWorkflowsByDefault ,
@@ -2251,6 +2256,7 @@ function buildPolicyData(options: BuildPolicyDataOptions = {}) {
22512256 return { successData, optimisticData, failureData, params} ;
22522257}
22532258
2259+ // eslint-disable-next-line @typescript-eslint/max-params
22542260function createWorkspace (
22552261 policyOwnerEmail = '' ,
22562262 makeMeAdmin = false ,
@@ -2262,6 +2268,7 @@ function createWorkspace(
22622268 shouldAddOnboardingTasks = true ,
22632269 companySize ?: OnboardingCompanySize ,
22642270 userReportedIntegration ?: OnboardingAccounting ,
2271+ isAnnualSubscription = false ,
22652272) : CreateWorkspaceParams {
22662273 const { optimisticData, failureData, successData, params} = buildPolicyData ( {
22672274 policyOwnerEmail,
@@ -2274,6 +2281,7 @@ function createWorkspace(
22742281 shouldAddOnboardingTasks,
22752282 companySize,
22762283 userReportedIntegration,
2284+ isAnnualSubscription,
22772285 } ) ;
22782286
22792287 API . write ( WRITE_COMMANDS . CREATE_WORKSPACE , params , { optimisticData, successData, failureData} ) ;
0 commit comments