Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
};

const deprecatedAllPolicies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 208 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
callback: (val, key) => {
if (!key) {
Expand All @@ -221,7 +221,7 @@
});

let deprecatedAllReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 224 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -231,7 +231,7 @@

let deprecatedSessionEmail = '';
let deprecatedSessionAccountID = 0;
Onyx.connect({

Check warning on line 234 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (val) => {
deprecatedSessionEmail = val?.email ?? '';
Expand All @@ -240,7 +240,7 @@
});

let deprecatedAllPersonalDetails: OnyxEntry<PersonalDetailsList>;
Onyx.connect({

Check warning on line 243 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (val) => (deprecatedAllPersonalDetails = val),
});
Expand Down Expand Up @@ -2695,6 +2695,7 @@
const isWorkflowsOptionSelected = parts?.exportLayouts;
const isPerDiemOptionSelected = parts?.perDiem;
const isOverviewOptionSelected = parts?.overview;
const isTravelOptionSelected = parts?.travel;

const outputCurrency = isOverviewOptionSelected ? policy?.outputCurrency : localCurrency;

Expand Down Expand Up @@ -2727,6 +2728,8 @@
areReportFieldsEnabled: isReportsOptionSelected,
areConnectionsEnabled: isConnectionsOptionSelected,
arePerDiemRatesEnabled: isPerDiemOptionSelected,
isTravelEnabled: isTravelOptionSelected ? policy?.isTravelEnabled : undefined,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear travel settings when travel isn’t selected

When duplicating a workspace that already has travel configured, deselecting Travel only flips isTravelEnabled but the new policy is still seeded from ...policy, so travelSettings (e.g., accepted terms / Spotnana IDs) gets copied into the duplicate. Since getTravelStep uses policy.travelSettings.hasAcceptedTerms without checking isTravelEnabled, a user who opted out of copying Travel can still see the duplicated workspace treated as provisioned (e.g., “Book or manage your trip”) if they navigate to the travel page. Consider explicitly clearing travelSettings when parts.travel is false.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont want to copy travelSettings

travelSettings: undefined,
workspaceAccountID: undefined,
tax: isTaxesOptionSelected ? policy?.tax : undefined,
employeeList: isMemberOptionSelected ? policy.employeeList : {[policy.owner]: policy?.employeeList?.[policy.owner]},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ function WorkspaceDuplicateSelectFeaturesForm({policyID}: WorkspaceDuplicateForm
alternateText: bankAccountList ? `${Object.keys(bankAccountList).length} ${translate('common.bankAccounts').toLowerCase()}, ${invoiceCompany}` : invoiceCompany,
}
: undefined,
policy?.isTravelEnabled
? {
translation: translate('workspace.common.travel'),
value: 'travel',
}
: undefined,
];

return result.filter((item): item is NonNullable<typeof item> => !!item);
Expand Down Expand Up @@ -228,6 +234,7 @@ function WorkspaceDuplicateSelectFeaturesForm({policyID}: WorkspaceDuplicateForm
invoices: selectedItems.includes('invoices'),
exportLayouts: selectedItems.includes('workflows'),
overview: selectedItems.includes('overview'),
travel: selectedItems.includes('travel'),
},
file: duplicatedWorkspaceAvatar,
localCurrency: currentUserPersonalDetails?.localCurrencyCode ?? '',
Expand Down
Loading