diff --git a/src/languages/en.ts b/src/languages/en.ts
index e9a3a109f830..38fb14639fca 100755
--- a/src/languages/en.ts
+++ b/src/languages/en.ts
@@ -2562,6 +2562,8 @@ const translations = {
other: (count: number) => `${count} selected`,
}),
settlementFrequency: 'Settlement frequency',
+ setAsDefault: 'Set as default workspace',
+ defaultNote: `Receipts sent to ${CONST.EMAIL.RECEIPTS} will appear in this workspace.`,
deleteConfirmation: 'Are you sure you want to delete this workspace?',
deleteWithCardsConfirmation: 'Are you sure you want to delete this workspace? This will remove all card feeds and assigned cards.',
unavailable: 'Unavailable workspace',
diff --git a/src/languages/es.ts b/src/languages/es.ts
index f6c3c4d34fbe..a2f663e3ffab 100644
--- a/src/languages/es.ts
+++ b/src/languages/es.ts
@@ -2585,6 +2585,8 @@ const translations = {
other: (count: number) => `${count} seleccionados`,
}),
settlementFrequency: 'Frecuencia de liquidación',
+ setAsDefault: 'Establecer como espacio de trabajo predeterminado',
+ defaultNote: `Los recibos enviados a ${CONST.EMAIL.RECEIPTS} aparecerán en este espacio de trabajo.`,
deleteConfirmation: '¿Estás seguro de que quieres eliminar este espacio de trabajo?',
deleteWithCardsConfirmation: '¿Estás seguro de que quieres eliminar este espacio de trabajo? Se eliminarán todos los datos de las tarjetas y las tarjetas asignadas.',
unavailable: 'Espacio de trabajo no disponible',
diff --git a/src/libs/API/parameters/SetNameValuePairParams.ts b/src/libs/API/parameters/SetNameValuePairParams.ts
index bc83d431224b..e09ea4cae69f 100644
--- a/src/libs/API/parameters/SetNameValuePairParams.ts
+++ b/src/libs/API/parameters/SetNameValuePairParams.ts
@@ -1,6 +1,6 @@
type SetNameValuePairParams = {
name: string;
- value: boolean;
+ value: boolean | string;
};
export default SetNameValuePairParams;
diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts
index 6d298ebcb1dd..f18fac18aca2 100644
--- a/src/libs/actions/Policy/Policy.ts
+++ b/src/libs/actions/Policy/Policy.ts
@@ -38,6 +38,7 @@ import type {
OpenWorkspaceInvitePageParams,
OpenWorkspaceParams,
RequestExpensifyCardLimitIncreaseParams,
+ SetNameValuePairParams,
SetPolicyAutomaticApprovalLimitParams,
SetPolicyAutomaticApprovalRateParams,
SetPolicyAutoReimbursementLimitParams,
@@ -824,6 +825,37 @@ function leaveWorkspace(policyID?: string) {
API.write(WRITE_COMMANDS.LEAVE_POLICY, params, {optimisticData, successData, failureData});
}
+function updateDefaultPolicy(newPolicyID?: string, oldPolicyID?: string) {
+ if (!newPolicyID) {
+ return;
+ }
+ const optimisticData: OnyxUpdate[] = [
+ {
+ onyxMethod: Onyx.METHOD.MERGE,
+ key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
+ value: newPolicyID,
+ },
+ ];
+
+ const failureData: OnyxUpdate[] = [
+ {
+ onyxMethod: Onyx.METHOD.MERGE,
+ key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
+ value: oldPolicyID,
+ },
+ ];
+
+ const parameters: SetNameValuePairParams = {
+ name: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
+ value: newPolicyID,
+ };
+
+ API.write(WRITE_COMMANDS.SET_NAME_VALUE_PAIR, parameters, {
+ optimisticData,
+ failureData,
+ });
+}
+
function addBillingCardAndRequestPolicyOwnerChange(
policyID: string,
cardData: {
@@ -4797,6 +4829,7 @@ export {
verifySetupIntentAndRequestPolicyOwnerChange,
updateInvoiceCompanyName,
updateInvoiceCompanyWebsite,
+ updateDefaultPolicy,
getAssignedSupportData,
downgradeToTeam,
};
diff --git a/src/pages/workspace/WorkspacesListPage.tsx b/src/pages/workspace/WorkspacesListPage.tsx
index 881abc569b4b..79aceafeeb90 100755
--- a/src/pages/workspace/WorkspacesListPage.tsx
+++ b/src/pages/workspace/WorkspacesListPage.tsx
@@ -117,6 +117,7 @@ function WorkspacesListPage() {
const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT);
const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
const [session] = useOnyx(ONYXKEYS.SESSION);
+ const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP);
const shouldShowLoadingIndicator = isLoadingApp && !isOffline;
@@ -170,6 +171,7 @@ function WorkspacesListPage() {
({item, index}: GetMenuItem) => {
const isAdmin = PolicyUtils.isPolicyAdmin(item as unknown as PolicyType, session?.email);
const isOwner = item.ownerAccountID === session?.accountID;
+ const isDefault = activePolicyID === item.policyID;
// Menu options to navigate to the chat report of #admins and #announce room.
// For navigation, the chat report ids may be unavailable due to the missing chat reports in Onyx.
// In such cases, let us use the available chat report ids from the policy.
@@ -222,6 +224,14 @@ function WorkspacesListPage() {
});
}
+ if (!isDefault && !item?.isJoinRequestPending) {
+ threeDotsMenuItems.push({
+ icon: Expensicons.Star,
+ text: translate('workspace.common.setAsDefault'),
+ onSelected: () => Policy.updateDefaultPolicy(item.policyID, activePolicyID),
+ });
+ }
+
return (
)}
@@ -268,6 +279,7 @@ function WorkspacesListPage() {
styles.offlineFeedback.deleted,
session?.accountID,
session?.email,
+ activePolicyID,
isSupportalAction,
],
);
diff --git a/src/pages/workspace/WorkspacesListRow.tsx b/src/pages/workspace/WorkspacesListRow.tsx
index 684f7a080e2e..3c270d708e11 100644
--- a/src/pages/workspace/WorkspacesListRow.tsx
+++ b/src/pages/workspace/WorkspacesListRow.tsx
@@ -10,6 +10,7 @@ import * as Illustrations from '@components/Icon/Illustrations';
import type {PopoverMenuItem} from '@components/PopoverMenu';
import Text from '@components/Text';
import ThreeDotsMenu from '@components/ThreeDotsMenu';
+import Tooltip from '@components/Tooltip';
import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails';
import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails';
import WorkspacesListRowDisplayName from '@components/WorkspacesListRowDisplayName';
@@ -65,6 +66,9 @@ type WorkspacesListRowProps = WithCurrentUserPersonalDetailsProps & {
/** ID of the policy */
policyID?: string;
+
+ /** is policy defualt */
+ isDefault?: boolean;
};
type BrickRoadIndicatorIconProps = {
@@ -108,6 +112,7 @@ function WorkspacesListRow({
shouldDisableThreeDotsMenu,
isJoinRequestPending,
policyID,
+ isDefault,
}: WorkspacesListRowProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
@@ -140,6 +145,20 @@ function WorkspacesListRow({
/>
)}
+ {!!isDefault && (
+
+
+
+
+
+ )}
{!isJoinRequestPending && (