From 646b6897f40b6e9ca4d964b97dbfb999c6e37eac Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:43:46 +0300 Subject: [PATCH 001/102] add spend route --- src/ROUTES.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index a8786bda3ffb..3b493740d8ca 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -486,6 +486,10 @@ const ROUTES = { route: 'workspace/:policyID/workflows', getRoute: (policyID: string) => `workspace/${policyID}/workflows` as const, }, + WORKSPACE_WORKFLOWS_SPEND_APPROVER: { + route: 'workspace/:policyId/workflows/spend/approver', + getRoute: (policyId: string) => `workspace/${policyId}/workflow/spend/approver` as const, + }, WORKSPACE_CARD: { route: 'workspace/:policyID/card', getRoute: (policyID: string) => `workspace/${policyID}/card` as const, From 08b1ed22611875aa4dcb771149736d35dccbbb3b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:43:57 +0300 Subject: [PATCH 002/102] add spend route --- src/SCREENS.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 520895c89c98..2d5f90b85a71 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -216,6 +216,7 @@ const SCREENS = { CATEGORIES: 'Workspace_Categories', CURRENCY: 'Workspace_Profile_Currency', WORKFLOWS: 'Workspace_Workflows', + WORKFLOWS_SPEND_APPROVER: 'Workspace_Workflows_Spend_Approver', DESCRIPTION: 'Workspace_Profile_Description', SHARE: 'Workspace_Profile_Share', NAME: 'Workspace_Profile_Name', From 52d78fa5761b96f24c3b258da51250ce294b19f5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:44:22 +0300 Subject: [PATCH 003/102] add approver to stack nav --- src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx | 1 + src/libs/Navigation/linkingConfig/config.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx index 0ecbe7a03d87..9d1a8e2ebde0 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx @@ -252,6 +252,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage').default as React.ComponentType, [SCREENS.WORKSPACE.RATE_AND_UNIT_UNIT]: () => require('../../../pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage').default as React.ComponentType, [SCREENS.WORKSPACE.INVITE]: () => require('../../../pages/workspace/WorkspaceInvitePage').default as React.ComponentType, + [SCREENS.WORKSPACE.WORKFLOWS_SPEND_APPROVER]: () => require('../../../pages/workspace/workflows/WorkspaceWorkflowsApproverPage').default as React.ComponentType, [SCREENS.WORKSPACE.INVITE_MESSAGE]: () => require('../../../pages/workspace/WorkspaceInviteMessagePage').default as React.ComponentType, [SCREENS.WORKSPACE.NAME]: () => require('../../../pages/workspace/WorkspaceNamePage').default as React.ComponentType, [SCREENS.WORKSPACE.DESCRIPTION]: () => require('../../../pages/workspace/WorkspaceProfileDescriptionPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 48d649cc4dd9..b282405f8d7e 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -256,6 +256,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.INVITE]: { path: ROUTES.WORKSPACE_INVITE.route, }, + [SCREENS.WORKSPACE.WORKFLOWS_SPEND_APPROVER]: { + path: ROUTES.WORKSPACE_WORKFLOWS_SPEND_APPROVER.route, + }, [SCREENS.WORKSPACE.INVITE_MESSAGE]: { path: ROUTES.WORKSPACE_INVITE_MESSAGE.route, }, From e30eb65fccaa918047287ab6b7b66422bf2e57ba Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:45:00 +0300 Subject: [PATCH 004/102] open workflow page on click --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index fc1ed1d19560..b4b15034601c 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -10,6 +10,7 @@ import useNetwork from '@hooks/useNetwork'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportUtils from '@libs/ReportUtils'; @@ -19,6 +20,7 @@ import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import ToggleSettingOptionRow from './ToggleSettingsOptionRow'; import type {ToggleSettingOptionRowProps} from './ToggleSettingsOptionRow'; @@ -74,7 +76,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { titleStyle={styles.textLabelSupportingNormal} descriptionTextStyle={styles.textNormalThemeText} description={policyOwnerDisplayName ?? ''} - // onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVER.getRoute(route.params.policyID))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOW_SPEND_APPROVER.getRoute(route.params.policyID))} // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon wrapperStyle={containerStyle} From b45c1062ec714c4b4d853cbe7d9394d3e2783c4d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:45:16 +0300 Subject: [PATCH 005/102] add dummy approver page --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx new file mode 100644 index 000000000000..5e7502ff2429 --- /dev/null +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -0,0 +1,3 @@ +function WorkspaceWorkflowsApproverPage() {} + +export default WorkspaceWorkflowsApproverPage; From c335676613e2342d387f4d5299f0658475e6a5ed Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:46:58 +0300 Subject: [PATCH 006/102] fix linking --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index b4b15034601c..da70aacbbe94 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -76,7 +76,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { titleStyle={styles.textLabelSupportingNormal} descriptionTextStyle={styles.textNormalThemeText} description={policyOwnerDisplayName ?? ''} - onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOW_SPEND_APPROVER.getRoute(route.params.policyID))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_SPEND_APPROVER.getRoute(route.params.policyID))} // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon wrapperStyle={containerStyle} From 7028951aaed96f57c98768b66bff41dd25bfd38f Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:49:42 +0300 Subject: [PATCH 007/102] fix tpo --- src/ROUTES.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 3b493740d8ca..127ca2a27afc 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -488,7 +488,7 @@ const ROUTES = { }, WORKSPACE_WORKFLOWS_SPEND_APPROVER: { route: 'workspace/:policyId/workflows/spend/approver', - getRoute: (policyId: string) => `workspace/${policyId}/workflow/spend/approver` as const, + getRoute: (policyId: string) => `workspace/${policyId}/workflows/spend/approver` as const, }, WORKSPACE_CARD: { route: 'workspace/:policyID/card', From 15704d474191d1da2117b38a290cbff6af09f948 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:59:43 +0300 Subject: [PATCH 008/102] rename --- src/ROUTES.ts | 6 +++--- src/libs/API/types.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 2 +- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 127ca2a27afc..09eab557b283 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -486,9 +486,9 @@ const ROUTES = { route: 'workspace/:policyID/workflows', getRoute: (policyID: string) => `workspace/${policyID}/workflows` as const, }, - WORKSPACE_WORKFLOWS_SPEND_APPROVER: { - route: 'workspace/:policyId/workflows/spend/approver', - getRoute: (policyId: string) => `workspace/${policyId}/workflows/spend/approver` as const, + WORKSPACE_WORKFLOWS_APPROVER: { + route: 'workspace/:policyId/workflows/approver', + getRoute: (policyId: string) => `workspace/${policyId}/workflows/approver` as const, }, WORKSPACE_CARD: { route: 'workspace/:policyID/card', diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 17cc366ba3b7..beeec04fa44e 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -10,6 +10,7 @@ type ApiRequest = ValueOf; const WRITE_COMMANDS = { SET_WORKSPACE_AUTO_REPORTING: 'SetWorkspaceAutoReporting', SET_WORKSPACE_APPROVAL_MODE: 'SetWorkspaceApprovalMode', + SET_WORKSPACE_APPROVER: 'SetWorkspaceApprover', DISMISS_REFERRAL_BANNER: 'DismissReferralBanner', UPDATE_PREFERRED_LOCALE: 'UpdatePreferredLocale', RECONNECT_APP: 'ReconnectApp', diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index b282405f8d7e..e50a71d9f9cb 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -257,7 +257,7 @@ const config: LinkingOptions['config'] = { path: ROUTES.WORKSPACE_INVITE.route, }, [SCREENS.WORKSPACE.WORKFLOWS_SPEND_APPROVER]: { - path: ROUTES.WORKSPACE_WORKFLOWS_SPEND_APPROVER.route, + path: ROUTES.WORKSPACE_WORKFLOWS_APPROVER.route, }, [SCREENS.WORKSPACE.INVITE_MESSAGE]: { path: ROUTES.WORKSPACE_INVITE_MESSAGE.route, diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index da70aacbbe94..60588cffba36 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -76,7 +76,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { titleStyle={styles.textLabelSupportingNormal} descriptionTextStyle={styles.textNormalThemeText} description={policyOwnerDisplayName ?? ''} - onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_SPEND_APPROVER.getRoute(route.params.policyID))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVER.getRoute(route.params.policyID))} // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon wrapperStyle={containerStyle} From 90beac6b3c393b5be6de0d69084d83156b575461 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 16:02:01 +0300 Subject: [PATCH 009/102] rename: remove spend --- src/SCREENS.ts | 2 +- src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx | 2 +- src/libs/Navigation/linkingConfig/config.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 2d5f90b85a71..7c0c3c39a835 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -216,7 +216,7 @@ const SCREENS = { CATEGORIES: 'Workspace_Categories', CURRENCY: 'Workspace_Profile_Currency', WORKFLOWS: 'Workspace_Workflows', - WORKFLOWS_SPEND_APPROVER: 'Workspace_Workflows_Spend_Approver', + WORKFLOWS_APPROVER: 'Workspace_Workflows_Approver', DESCRIPTION: 'Workspace_Profile_Description', SHARE: 'Workspace_Profile_Share', NAME: 'Workspace_Profile_Name', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx index 9d1a8e2ebde0..53aaa2008c3d 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx @@ -252,7 +252,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage').default as React.ComponentType, [SCREENS.WORKSPACE.RATE_AND_UNIT_UNIT]: () => require('../../../pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage').default as React.ComponentType, [SCREENS.WORKSPACE.INVITE]: () => require('../../../pages/workspace/WorkspaceInvitePage').default as React.ComponentType, - [SCREENS.WORKSPACE.WORKFLOWS_SPEND_APPROVER]: () => require('../../../pages/workspace/workflows/WorkspaceWorkflowsApproverPage').default as React.ComponentType, + [SCREENS.WORKSPACE.WORKFLOWS_APPROVER]: () => require('../../../pages/workspace/workflows/WorkspaceWorkflowsApproverPage').default as React.ComponentType, [SCREENS.WORKSPACE.INVITE_MESSAGE]: () => require('../../../pages/workspace/WorkspaceInviteMessagePage').default as React.ComponentType, [SCREENS.WORKSPACE.NAME]: () => require('../../../pages/workspace/WorkspaceNamePage').default as React.ComponentType, [SCREENS.WORKSPACE.DESCRIPTION]: () => require('../../../pages/workspace/WorkspaceProfileDescriptionPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index e50a71d9f9cb..838219a63e8a 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -256,7 +256,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.INVITE]: { path: ROUTES.WORKSPACE_INVITE.route, }, - [SCREENS.WORKSPACE.WORKFLOWS_SPEND_APPROVER]: { + [SCREENS.WORKSPACE.WORKFLOWS_APPROVER]: { path: ROUTES.WORKSPACE_WORKFLOWS_APPROVER.route, }, [SCREENS.WORKSPACE.INVITE_MESSAGE]: { From e254f56449c08f3b906f5efa76b86b1ad72efe56 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 16:15:50 +0300 Subject: [PATCH 010/102] add api type --- src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 0b0a81eb21f8..3214af820ae1 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -147,4 +147,5 @@ export type {default as AcceptACHContractForBankAccount} from './AcceptACHContra export type {default as UpdateWorkspaceDescriptionParams} from './UpdateWorkspaceDescriptionParams'; export type {default as SetWorkspaceAutoReportingParams} from './SetWorkspaceAutoReportingParams'; export type {default as SetWorkspaceApprovalModeParams} from './SetWorkspaceApprovalModeParams'; +export type {default as SetWorkspaceWorkflowsApproverParams} from './SetWorkspaceWorkflowsApproverParams'; export type {default as SwitchToOldDotParams} from './SwitchToOldDotParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index beeec04fa44e..e2ea1143a8d2 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -297,6 +297,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.ACCEPT_ACH_CONTRACT_FOR_BANK_ACCOUNT]: Parameters.AcceptACHContractForBankAccount; [WRITE_COMMANDS.UPDATE_WORKSPACE_DESCRIPTION]: Parameters.UpdateWorkspaceDescriptionParams; [WRITE_COMMANDS.SET_WORKSPACE_AUTO_REPORTING]: Parameters.SetWorkspaceAutoReportingParams; + [WRITE_COMMANDS.SET_WORKSPACE_APPROVER]: Parameters.SetWorkspaceWorkflowsApproverParams; [WRITE_COMMANDS.SET_WORKSPACE_APPROVAL_MODE]: Parameters.SetWorkspaceApprovalModeParams; [WRITE_COMMANDS.SWITCH_TO_OLD_DOT]: Parameters.SwitchToOldDotParams; }; From bcd89b7507ecb11fda06df47f74dc739f66b4e2e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 16:16:24 +0300 Subject: [PATCH 011/102] link write api params --- .../API/parameters/SetWorkspaceWorkflowsApproverParams.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts diff --git a/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts b/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts new file mode 100644 index 000000000000..cf1d4a2e705b --- /dev/null +++ b/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts @@ -0,0 +1,6 @@ +type SetWorkspaceWorkflowsApproverParams = { + policyID: string; + accountID: number; +}; + +export default SetWorkspaceWorkflowsApproverParams; From c814c514ea175c5701afc4fb9f0eda1ddc9d38f4 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 17:08:09 +0300 Subject: [PATCH 012/102] fix policy id route --- src/ROUTES.ts | 2 +- .../WorkspaceWorkflowsApproverPage.tsx | 32 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 09eab557b283..8ae3125e728d 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -487,7 +487,7 @@ const ROUTES = { getRoute: (policyID: string) => `workspace/${policyID}/workflows` as const, }, WORKSPACE_WORKFLOWS_APPROVER: { - route: 'workspace/:policyId/workflows/approver', + route: 'workspace/:policyID/workflows/approver', getRoute: (policyId: string) => `workspace/${policyId}/workflows/approver` as const, }, WORKSPACE_CARD: { diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 5e7502ff2429..669d94247055 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,3 +1,31 @@ -function WorkspaceWorkflowsApproverPage() {} +import React from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import useLocalize from '@hooks/useLocalize'; +import Navigation from '@libs/Navigation/Navigation'; +import withPolicy, {WithPolicyOnyxProps} from '@pages/workspace/withPolicy'; -export default WorkspaceWorkflowsApproverPage; +type WorkspaceWorkflowsApproverPageProps = WithPolicyOnyxProps; + +function WorkspaceWorkflowsApproverPage({policy}: WorkspaceWorkflowsApproverPageProps) { + const {translate} = useLocalize(); + const policyName = policy?.name ?? ''; + console.log(policy); + + return ( + + + + ); +} + +WorkspaceWorkflowsApproverPage.displayName = 'WorkspaceWorkflowsApproverPage'; + +export default withPolicy(WorkspaceWorkflowsApproverPage); From d4e4de13bed06fb1fa2cd972b68e843055f4310a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 17:10:27 +0300 Subject: [PATCH 013/102] rm console --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 669d94247055..fdba10dd324c 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -10,7 +10,6 @@ type WorkspaceWorkflowsApproverPageProps = WithPolicyOnyxProps; function WorkspaceWorkflowsApproverPage({policy}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; - console.log(policy); return ( Date: Tue, 27 Feb 2024 17:12:23 +0300 Subject: [PATCH 014/102] use policy members --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index fdba10dd324c..4b6493e6e31d 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -7,9 +7,10 @@ import withPolicy, {WithPolicyOnyxProps} from '@pages/workspace/withPolicy'; type WorkspaceWorkflowsApproverPageProps = WithPolicyOnyxProps; -function WorkspaceWorkflowsApproverPage({policy}: WorkspaceWorkflowsApproverPageProps) { +function WorkspaceWorkflowsApproverPage({policy, policyMembers}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; + console.log(policy, policyMembers); return ( Date: Tue, 27 Feb 2024 19:24:04 +0300 Subject: [PATCH 015/102] add settings to routes as per doc --- src/ROUTES.ts | 4 +- .../WorkspaceWorkflowsApproverPage.tsx | 39 ++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 8ae3125e728d..6f3034dca4c2 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -487,8 +487,8 @@ const ROUTES = { getRoute: (policyID: string) => `workspace/${policyID}/workflows` as const, }, WORKSPACE_WORKFLOWS_APPROVER: { - route: 'workspace/:policyID/workflows/approver', - getRoute: (policyId: string) => `workspace/${policyId}/workflows/approver` as const, + route: 'workspace/:policyID/settings/workflows/approver', + getRoute: (policyId: string) => `workspace/${policyId}/settings/workflows/approver` as const, }, WORKSPACE_CARD: { route: 'workspace/:policyID/card', diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 4b6493e6e31d..5fd5958cc6d1 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,17 +1,43 @@ -import React from 'react'; +import React, {useMemo, useState} from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; +import SelectionList from '@components/SelectionList'; +import UserListItem from '@components/SelectionList/UserListItem'; import useLocalize from '@hooks/useLocalize'; import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; import withPolicy, {WithPolicyOnyxProps} from '@pages/workspace/withPolicy'; +import type {Section} from '@components/SelectionList/types'; +import useNetwork from '@hooks/useNetwork'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as DeviceCapabilities from '@libs/DeviceCapabilities'; +import * as LoginUtils from '@libs/LoginUtils'; +import type {MemberForList} from '@libs/OptionsListUtils'; +import {parsePhoneNumber} from '@libs/PhoneNumber'; +import * as PolicyUtils from '@libs/PolicyUtils'; +import type {OptionData} from '@libs/ReportUtils'; +import type {SettingsNavigatorParamList} from '@navigation/types'; +import * as Policy from '@userActions/Policy'; +import { SectionListData } from 'react-native'; type WorkspaceWorkflowsApproverPageProps = WithPolicyOnyxProps; +type MembersSection = SectionListData>; function WorkspaceWorkflowsApproverPage({policy, policyMembers}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; + const [searchTerm, setSearchTerm] = useState(''); + const headerMessage = useMemo(() => { + const searchValue = searchTerm.trim().toLowerCase(); + return OptionsListUtils.getHeaderMessage(true, false, searchValue); + }, [translate, searchTerm, policyName]); + console.log(policy, policyMembers); + const sections: MembersSection[] = () => { + + } + return ( + {}} + // initiallyFocusedOptionKey={0} + showScrollIndicator + /> ); } From 353d350dd0d2d3f4697886b37e04b1e932d8c703 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 21:03:22 +0300 Subject: [PATCH 016/102] get personal details for policy members --- .../WorkspaceWorkflowsApproverPage.tsx | 49 ++++++++++++++----- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 5fd5958cc6d1..352c51132a7b 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,29 +1,41 @@ import React, {useMemo, useState} from 'react'; +import {SectionListData} from 'react-native'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; +import type {Section} from '@components/SelectionList/types'; import UserListItem from '@components/SelectionList/UserListItem'; import useLocalize from '@hooks/useLocalize'; -import Navigation from '@libs/Navigation/Navigation'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; -import withPolicy, {WithPolicyOnyxProps} from '@pages/workspace/withPolicy'; -import type {Section} from '@components/SelectionList/types'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; +import compose from '@libs/compose'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import * as LoginUtils from '@libs/LoginUtils'; +import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; import type {MemberForList} from '@libs/OptionsListUtils'; +import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {parsePhoneNumber} from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import type {OptionData} from '@libs/ReportUtils'; import type {SettingsNavigatorParamList} from '@navigation/types'; +import withPolicy, {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as Policy from '@userActions/Policy'; -import { SectionListData } from 'react-native'; +import ONYXKEYS from '@src/ONYXKEYS'; +import {Beta, InvitedEmailsToAccountIDs, PersonalDetailsList} from '@src/types/onyx'; +import withPolicyAndFullscreenLoading from '../withPolicyAndFullscreenLoading'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; -type WorkspaceWorkflowsApproverPageProps = WithPolicyOnyxProps; +type WorkspaceWorkflowsApproverPageOnyxProps = { + /** All of the personal details for everyone */ + personalDetails: OnyxEntry; +}; + +type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxProps & WithPolicyProps; type MembersSection = SectionListData>; -function WorkspaceWorkflowsApproverPage({policy, policyMembers}: WorkspaceWorkflowsApproverPageProps) { +function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; const [searchTerm, setSearchTerm] = useState(''); @@ -31,12 +43,16 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers}: WorkspaceWorkfl const searchValue = searchTerm.trim().toLowerCase(); return OptionsListUtils.getHeaderMessage(true, false, searchValue); }, [translate, searchTerm, policyName]); + const currentUserPersonalDetails = useCurrentUserPersonalDetails(); + + const policyMemberAccountIDs = Object.keys(policyMembers ?? {}).map((accountId) => parseInt(accountId)); + const workspaceMembers = PersonalDetailsUtils.getPersonalDetailsByIDs(policyMemberAccountIDs, currentUserPersonalDetails.accountID); + console.log('[workspaceMembers]: ', workspaceMembers); - console.log(policy, policyMembers); + // const sections: MembersSection[] = () => { + // const sectionsArr: MembersSection[] = []; - const sections: MembersSection[] = () => { - - } + // }; return ( ({ + personalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, + }), + withPolicy, +)(WorkspaceWorkflowsApproverPage); From c65636b66b692063e2bf739e28ac911ee7e32062 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 04:54:11 +0300 Subject: [PATCH 017/102] get personal details for policy members --- src/libs/OptionsListUtils.ts | 2 +- .../WorkspaceWorkflowsApproverPage.tsx | 31 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 3d11795f5452..cea2616651c6 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1874,7 +1874,7 @@ function formatMemberForList(member: ReportUtils.OptionData): MemberForList { login: member.login ?? '', icons: member.icons, pendingAction: member.pendingAction, - reportID: member.reportID, + reportID: member.reportID ?? '', }; } diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 352c51132a7b..c550b9ca3171 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,11 +1,13 @@ +import Str from 'expensify-common/lib/str'; import React, {useMemo, useState} from 'react'; import {SectionListData} from 'react-native'; import {OnyxEntry, withOnyx} from 'react-native-onyx'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; -import type {Section} from '@components/SelectionList/types'; +import type {ListItem, Section} from '@components/SelectionList/types'; import UserListItem from '@components/SelectionList/UserListItem'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -23,17 +25,17 @@ import type {SettingsNavigatorParamList} from '@navigation/types'; import withPolicy, {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as Policy from '@userActions/Policy'; import ONYXKEYS from '@src/ONYXKEYS'; -import {Beta, InvitedEmailsToAccountIDs, PersonalDetailsList} from '@src/types/onyx'; +import {Beta, InvitedEmailsToAccountIDs, PersonalDetails, PersonalDetailsList} from '@src/types/onyx'; import withPolicyAndFullscreenLoading from '../withPolicyAndFullscreenLoading'; -import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; +import type {WithPolicyAndFullscreenLoadingProps} from '../withPolicyAndFullscreenLoading'; type WorkspaceWorkflowsApproverPageOnyxProps = { /** All of the personal details for everyone */ personalDetails: OnyxEntry; }; -type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxProps & WithPolicyProps; -type MembersSection = SectionListData>; +type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxProps & WithPolicyAndFullscreenLoadingProps; +type MembersSection = SectionListData>; function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); @@ -43,16 +45,15 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} const searchValue = searchTerm.trim().toLowerCase(); return OptionsListUtils.getHeaderMessage(true, false, searchValue); }, [translate, searchTerm, policyName]); - const currentUserPersonalDetails = useCurrentUserPersonalDetails(); - const policyMemberAccountIDs = Object.keys(policyMembers ?? {}).map((accountId) => parseInt(accountId)); - const workspaceMembers = PersonalDetailsUtils.getPersonalDetailsByIDs(policyMemberAccountIDs, currentUserPersonalDetails.accountID); - console.log('[workspaceMembers]: ', workspaceMembers); + const policyMemberAccountIDs = Object.keys(policyMembers ?? {}).map((accountId) => accountId); + const policyMemberDetails = policyMemberAccountIDs.filter((accountID) => !!personalDetails?.[accountID]).map((accountID) => personalDetails?.[accountID]); - // const sections: MembersSection[] = () => { - // const sectionsArr: MembersSection[] = []; + const sections: MembersSection[] = useMemo(() => { + let result: MembersSection[] = []; - // }; + return result; + }, [personalDetails, searchTerm, translate]); return ( Date: Wed, 28 Feb 2024 06:35:11 +0300 Subject: [PATCH 018/102] add check for approver --- .../WorkspaceWorkflowsApproverPage.tsx | 86 ++++++++++++++----- 1 file changed, 65 insertions(+), 21 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index c550b9ca3171..44a2ec519fe8 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,31 +1,26 @@ -import Str from 'expensify-common/lib/str'; import React, {useMemo, useState} from 'react'; -import {SectionListData} from 'react-native'; import {OnyxEntry, withOnyx} from 'react-native-onyx'; +import Badge from '@components/Badge'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; -import type {ListItem, Section} from '@components/SelectionList/types'; +import type {ListItem} from '@components/SelectionList/types'; import UserListItem from '@components/SelectionList/UserListItem'; -import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import compose from '@libs/compose'; -import * as DeviceCapabilities from '@libs/DeviceCapabilities'; -import * as LoginUtils from '@libs/LoginUtils'; +import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; +import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; -import type {MemberForList} from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; -import {parsePhoneNumber} from '@libs/PhoneNumber'; -import * as PolicyUtils from '@libs/PolicyUtils'; -import type {OptionData} from '@libs/ReportUtils'; -import type {SettingsNavigatorParamList} from '@navigation/types'; -import withPolicy, {WithPolicyProps} from '@pages/workspace/withPolicy'; -import * as Policy from '@userActions/Policy'; +import * as UserUtils from '@libs/UserUtils'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import {Beta, InvitedEmailsToAccountIDs, PersonalDetails, PersonalDetailsList} from '@src/types/onyx'; +import {PersonalDetailsList, PolicyMember} from '@src/types/onyx'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; import withPolicyAndFullscreenLoading from '../withPolicyAndFullscreenLoading'; import type {WithPolicyAndFullscreenLoadingProps} from '../withPolicyAndFullscreenLoading'; @@ -35,25 +30,74 @@ type WorkspaceWorkflowsApproverPageOnyxProps = { }; type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxProps & WithPolicyAndFullscreenLoadingProps; -type MembersSection = SectionListData>; +type MemberOption = Omit & {accountID: number}; function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; const [searchTerm, setSearchTerm] = useState(''); + const {isOffline} = useNetwork(); + const styles = useThemeStyles(); + const StyleUtils = useStyleUtils(); + const headerMessage = useMemo(() => { const searchValue = searchTerm.trim().toLowerCase(); return OptionsListUtils.getHeaderMessage(true, false, searchValue); }, [translate, searchTerm, policyName]); - const policyMemberAccountIDs = Object.keys(policyMembers ?? {}).map((accountId) => accountId); - const policyMemberDetails = policyMemberAccountIDs.filter((accountID) => !!personalDetails?.[accountID]).map((accountID) => personalDetails?.[accountID]); + const isDeletedPolicyMember = (policyMember: PolicyMember): boolean => + !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); + + const policyUsers: MemberOption[] = useMemo(() => { + let result: MemberOption[] = []; + Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { + const accountID = Number(accountIDKey); + if (isDeletedPolicyMember(policyMember)) { + return; + } + + const details = personalDetails?.[accountID]; + if (!details) { + Log.hmmm(`[WorkspaceMembersPage] no personal details found for policy member with accountID: ${accountID}`); + return; + } + + const isOwner = policy?.owner === details.login; + const isAdmin = policyMember.role === CONST.POLICY.ROLE.ADMIN; - const sections: MembersSection[] = useMemo(() => { - let result: MembersSection[] = []; + let roleBadge = null; + if (isOwner || isAdmin) { + roleBadge = ( + + ); + } + result.push({ + keyForList: accountIDKey, + accountID, + isSelected: policy?.approver === details.login, + isDisabled: policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !isEmptyObject(policyMember.errors), + text: formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(details)), + alternateText: formatPhoneNumber(details?.login ?? ''), + rightElement: roleBadge, + icons: [ + { + source: UserUtils.getAvatar(details.avatar, accountID), + name: formatPhoneNumber(details?.login ?? ''), + type: CONST.ICON_TYPE_AVATAR, + id: accountID, + }, + ], + errors: policyMember.errors, + pendingAction: policyMember.pendingAction, + }); + }); return result; - }, [personalDetails, searchTerm, translate]); + }, [personalDetails, policyMembers, searchTerm, translate]); return ( Date: Wed, 28 Feb 2024 07:07:03 +0300 Subject: [PATCH 019/102] add all section --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 44a2ec519fe8..0c8c9679bc88 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,10 +1,11 @@ import React, {useMemo, useState} from 'react'; +import {SectionListData} from 'react-native'; import {OnyxEntry, withOnyx} from 'react-native-onyx'; import Badge from '@components/Badge'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; -import type {ListItem} from '@components/SelectionList/types'; +import type {ListItem, Section} from '@components/SelectionList/types'; import UserListItem from '@components/SelectionList/UserListItem'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; From 1e4e5cb6848a34754d45f9cf346a5862939005a5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:07:11 +0300 Subject: [PATCH 020/102] add all section --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 0c8c9679bc88..0969d79d69eb 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -32,6 +32,7 @@ type WorkspaceWorkflowsApproverPageOnyxProps = { type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxProps & WithPolicyAndFullscreenLoadingProps; type MemberOption = Omit & {accountID: number}; +type MembersSection = SectionListData>; function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); From 4e0d42b8e5c1ea77cb441a00a374749fa7943040 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:07:17 +0300 Subject: [PATCH 021/102] add all section --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 0969d79d69eb..7a33719f1d11 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -50,8 +50,11 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} const isDeletedPolicyMember = (policyMember: PolicyMember): boolean => !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); - const policyUsers: MemberOption[] = useMemo(() => { - let result: MemberOption[] = []; + const sections: MembersSection[] = useMemo(() => { + let sectionsArr: MembersSection[] = []; + + let policyUsersSection: MemberOption[] = []; + Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { const accountID = Number(accountIDKey); if (isDeletedPolicyMember(policyMember)) { From 97dd3a2fa6bc1062980ffd7ee2c0d4afcba0a29e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:07:39 +0300 Subject: [PATCH 022/102] add all section 0 offset --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 7a33719f1d11..4c396accf373 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -81,7 +81,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} ); } - result.push({ + policyUsersSection.push({ keyForList: accountIDKey, accountID, isSelected: policy?.approver === details.login, From 54f846e1d85305dc40e981f7ec1668dc88684933 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:07:46 +0300 Subject: [PATCH 023/102] add all section 0 offset --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 4c396accf373..1a0d507e15fa 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -101,8 +101,16 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} pendingAction: policyMember.pendingAction, }); }); - return result; - }, [personalDetails, policyMembers, searchTerm, translate]); + + sectionsArr.push({ + title: translate('common.all'), + data: policyUsersSection, + shouldShow: true, + indexOffset: 0, + }); + + return sectionsArr; + }, [personalDetails, policyMembers, searchTerm, translate, policy?.approver]); return ( Date: Wed, 28 Feb 2024 07:07:57 +0300 Subject: [PATCH 024/102] add all section 0 offset --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 1a0d507e15fa..ebec25863444 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -123,7 +123,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} onBackButtonPress={Navigation.goBack} /> Date: Wed, 28 Feb 2024 07:13:29 +0300 Subject: [PATCH 025/102] add approver section --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index ebec25863444..779cf84d1b0b 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -54,6 +54,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} let sectionsArr: MembersSection[] = []; let policyUsersSection: MemberOption[] = []; + let approverSection: MemberOption[] = []; Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { const accountID = Number(accountIDKey); From 06399aa4c6adb82b5cb7caf58a9d34951a5179fc Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:13:36 +0300 Subject: [PATCH 026/102] add approver section --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 779cf84d1b0b..acc2e84183ba 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -82,7 +82,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} ); } - policyUsersSection.push({ + const formattedMember = { keyForList: accountIDKey, accountID, isSelected: policy?.approver === details.login, From eeaae976c2f5ec3d2d6635af8345a4b553bc55c5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:13:42 +0300 Subject: [PATCH 027/102] add approver section --- .../WorkspaceWorkflowsApproverPage.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index acc2e84183ba..fed693df1566 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -100,14 +100,27 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} ], errors: policyMember.errors, pendingAction: policyMember.pendingAction, - }); + }; + + if (policy?.approver === details.login) { + approverSection.push(formattedMember); + } else { + policyUsersSection.push(formattedMember); + } + }); + + sectionsArr.push({ + title: undefined, + data: approverSection, + shouldShow: true, + indexOffset: 0, }); sectionsArr.push({ title: translate('common.all'), data: policyUsersSection, shouldShow: true, - indexOffset: 0, + indexOffset: 1, }); return sectionsArr; From 8a058da01cd0aa610a043d21d4c28b73c6783ffa Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:22:26 +0300 Subject: [PATCH 028/102] fix index offset for all --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index fed693df1566..c227f39fbe29 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -120,7 +120,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} title: translate('common.all'), data: policyUsersSection, shouldShow: true, - indexOffset: 1, + indexOffset: approverSection.length, }); return sectionsArr; From 4c629b6d15dbfc389c24ce200a5562b7a027687d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:01:38 +0300 Subject: [PATCH 029/102] make api call on approver select --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index c227f39fbe29..8f684f30c8c6 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -18,6 +18,7 @@ import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as UserUtils from '@libs/UserUtils'; +import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import {PersonalDetailsList, PolicyMember} from '@src/types/onyx'; @@ -126,6 +127,13 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} return sectionsArr; }, [personalDetails, policyMembers, searchTerm, translate, policy?.approver]); + const setPolicyApprover = (member: MemberOption) => { + if (!policy) { + return; + } + Policy.setWorkspaceApprover(policy.id, member.accountID); + }; + return ( {}} + onSelectRow={setPolicyApprover} // initiallyFocusedOptionKey={0} showScrollIndicator /> From a9fc40510dd634ec3838324e20fdf84f88a07566 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:02:01 +0300 Subject: [PATCH 030/102] add set approver action --- src/libs/actions/Policy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 57cd4a6fc071..197a4eebcd49 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -22,6 +22,7 @@ import type { OpenWorkspaceReimburseViewParams, SetWorkspaceApprovalModeParams, SetWorkspaceAutoReportingParams, + SetWorkspaceWorkflowsApproverParams, UpdateWorkspaceAvatarParams, UpdateWorkspaceCustomUnitAndRateParams, UpdateWorkspaceDescriptionParams, From 73b8245ac41fd8f03a1eea993b2b1752fff84118 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:02:10 +0300 Subject: [PATCH 031/102] add set approver action --- src/libs/actions/Policy.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 197a4eebcd49..2f26d6b8b7a4 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -466,6 +466,41 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo API.write(WRITE_COMMANDS.SET_WORKSPACE_APPROVAL_MODE, params, {optimisticData, failureData, successData}); } +function setWorkspaceApprover(policyID: string, approverAccountID: number) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: {approver: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, + }, + }, + ]; + + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: {approver: null}, + }, + }, + ]; + + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: {approver: null}, + }, + }, + ]; + + const params: SetWorkspaceWorkflowsApproverParams = {policyID, accountID: approverAccountID}; + API.write(WRITE_COMMANDS.SET_WORKSPACE_APPROVER, params, {optimisticData, failureData, successData}); +} + /** * Build optimistic data for removing users from the announcement room */ From 89e42afb15d84b3d0f2850b3cbc3a9677e6f78d2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:02:15 +0300 Subject: [PATCH 032/102] add set approver action --- src/libs/actions/Policy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 2f26d6b8b7a4..a66211373af0 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2256,5 +2256,6 @@ export { setWorkspaceInviteMessageDraft, setWorkspaceAutoReporting, setWorkspaceApprovalMode, + setWorkspaceApprover, updateWorkspaceDescription, }; From 2f46ead4096a4070cf5eaf0527e19bea6d00377a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:02:58 +0300 Subject: [PATCH 033/102] go back on set approver --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 8f684f30c8c6..c698ea033c40 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -132,6 +132,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} return; } Policy.setWorkspaceApprover(policy.id, member.accountID); + Navigation.goBack(); }; return ( From 5a2ed4031781cdc9a2d24a8082405ea79718aff7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:03:30 +0300 Subject: [PATCH 034/102] rm comment --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index c698ea033c40..a1ea2daffab9 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -153,7 +153,6 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} headerMessage={headerMessage} ListItem={UserListItem} onSelectRow={setPolicyApprover} - // initiallyFocusedOptionKey={0} showScrollIndicator /> From a88070c78d0938c857bea8a53c7a0a00f03499f2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:22:28 +0300 Subject: [PATCH 035/102] fix lint --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index a1ea2daffab9..599a0a46d796 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -21,7 +21,7 @@ import * as UserUtils from '@libs/UserUtils'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import {PersonalDetailsList, PolicyMember} from '@src/types/onyx'; +import type {PersonalDetailsList, PolicyMember} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import withPolicyAndFullscreenLoading from '../withPolicyAndFullscreenLoading'; import type {WithPolicyAndFullscreenLoadingProps} from '../withPolicyAndFullscreenLoading'; @@ -52,10 +52,10 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); const sections: MembersSection[] = useMemo(() => { - let sectionsArr: MembersSection[] = []; + const sectionsArr: MembersSection[] = []; - let policyUsersSection: MemberOption[] = []; - let approverSection: MemberOption[] = []; + const policyUsersSection: MemberOption[] = []; + const approverSection: MemberOption[] = []; Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { const accountID = Number(accountIDKey); From 30655d825447969cf2f2bf8850e24673a46e3a74 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:50:47 +0300 Subject: [PATCH 036/102] rm setworkspace approver command --- src/libs/API/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index ed25278d6121..7a97405ce931 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -10,7 +10,6 @@ type ApiRequest = ValueOf; const WRITE_COMMANDS = { SET_WORKSPACE_AUTO_REPORTING: 'SetWorkspaceAutoReporting', SET_WORKSPACE_APPROVAL_MODE: 'SetWorkspaceApprovalMode', - SET_WORKSPACE_APPROVER: 'SetWorkspaceApprover', DISMISS_REFERRAL_BANNER: 'DismissReferralBanner', UPDATE_PREFERRED_LOCALE: 'UpdatePreferredLocale', OPEN_APP: 'OpenApp', From b894a345a3aca2f051422d0db7e93b08921ac735 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:50:55 +0300 Subject: [PATCH 037/102] rm setworkspace approver command --- src/libs/API/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 7a97405ce931..c6fd1154fbf1 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -300,7 +300,6 @@ type WriteCommandParameters = { [WRITE_COMMANDS.ACCEPT_ACH_CONTRACT_FOR_BANK_ACCOUNT]: Parameters.AcceptACHContractForBankAccount; [WRITE_COMMANDS.UPDATE_WORKSPACE_DESCRIPTION]: Parameters.UpdateWorkspaceDescriptionParams; [WRITE_COMMANDS.SET_WORKSPACE_AUTO_REPORTING]: Parameters.SetWorkspaceAutoReportingParams; - [WRITE_COMMANDS.SET_WORKSPACE_APPROVER]: Parameters.SetWorkspaceWorkflowsApproverParams; [WRITE_COMMANDS.SET_WORKSPACE_APPROVAL_MODE]: Parameters.SetWorkspaceApprovalModeParams; [WRITE_COMMANDS.SWITCH_TO_OLD_DOT]: Parameters.SwitchToOldDotParams; }; From 138edadb7949af151195508e958fdebb83a9392e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:51:02 +0300 Subject: [PATCH 038/102] rm setworkspace approver command --- src/libs/actions/Policy.ts | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 8f4a4c2f3300..b11dd7e44a5d 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -467,41 +467,6 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo API.write(WRITE_COMMANDS.SET_WORKSPACE_APPROVAL_MODE, params, {optimisticData, failureData, successData}); } -function setWorkspaceApprover(policyID: string, approverAccountID: number) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: {approver: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, - }, - }, - ]; - - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: {approver: null}, - }, - }, - ]; - - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: {approver: null}, - }, - }, - ]; - - const params: SetWorkspaceWorkflowsApproverParams = {policyID, accountID: approverAccountID}; - API.write(WRITE_COMMANDS.SET_WORKSPACE_APPROVER, params, {optimisticData, failureData, successData}); -} - /** * Build optimistic data for removing users from the announcement room */ From af43199502e30fd700f63053f6b652d9dd711648 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:51:11 +0300 Subject: [PATCH 039/102] rm setworkspace approver command --- src/libs/actions/Policy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index b11dd7e44a5d..5771c7ada1de 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2276,7 +2276,6 @@ export { setWorkspaceInviteMessageDraft, setWorkspaceAutoReporting, setWorkspaceApprovalMode, - setWorkspaceApprover, updateWorkspaceDescription, setWorkspaceRequiresCategory, }; From 324c529515c21889869051ca001f69c7b0df14a1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:51:33 +0300 Subject: [PATCH 040/102] use set policy approver mode --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 599a0a46d796..83a09e030625 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,6 +1,7 @@ import React, {useMemo, useState} from 'react'; import {SectionListData} from 'react-native'; -import {OnyxEntry, withOnyx} from 'react-native-onyx'; +import {withOnyx} from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; import Badge from '@components/Badge'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; From c0e4981a55b900ebff3011b8c9fb5862fbffd969 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:51:38 +0300 Subject: [PATCH 041/102] use set policy approver mode --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 83a09e030625..8ca60b66e10b 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -129,10 +129,12 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} }, [personalDetails, policyMembers, searchTerm, translate, policy?.approver]); const setPolicyApprover = (member: MemberOption) => { - if (!policy) { + if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { return; } - Policy.setWorkspaceApprover(policy.id, member.accountID); + const approver: string = personalDetails?.[member.accountID]?.login || policy.approver || ''; + console.log(approver); + Policy.setWorkspaceApprovalMode(policy.id, approver, policy.approvalMode); Navigation.goBack(); }; From 35e5d1828df5c965a102b13d4ac48bb4e881587b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:59:40 +0300 Subject: [PATCH 042/102] show policy approver --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 60588cffba36..8731407fe6fd 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -34,8 +34,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { const {isSmallScreenWidth} = useWindowDimensions(); const {isOffline} = useNetwork(); - const ownerPersonalDetails = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs([policy?.ownerAccountID ?? 0], CONST.EMPTY_OBJECT), false); - const policyOwnerDisplayName = ownerPersonalDetails[0]?.displayName; + const policyApprover = policy?.approver; const containerStyle = useMemo(() => [styles.ph8, styles.mhn8, styles.ml11, styles.pv3, styles.pr0, styles.pl4, styles.mr0, styles.widthAuto, styles.mt4], [styles]); const items: ToggleSettingOptionRowProps[] = useMemo( From a01f23c48ccea8a3b55d83ee0844ea5a222c1207 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:59:45 +0300 Subject: [PATCH 043/102] show policy approver --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 8731407fe6fd..362039baff00 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -74,7 +74,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { title={translate('workflowsPage.approver')} titleStyle={styles.textLabelSupportingNormal} descriptionTextStyle={styles.textNormalThemeText} - description={policyOwnerDisplayName ?? ''} + description={policyApprover ?? ''} onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVER.getRoute(route.params.policyID))} // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon From bd296622de8b3ffdbde9ca133d97d4e5ac77f75b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:59:51 +0300 Subject: [PATCH 044/102] show policy approver --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 362039baff00..afcf7351f219 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -109,7 +109,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { isActive: false, // TODO will be done in https://github.com/Expensify/Expensify/issues/368335 }, ], - [policy, route.params.policyID, styles, translate, policyOwnerDisplayName, containerStyle, isOffline, StyleUtils], + [policy, route.params.policyID, styles, translate, policyApprover, containerStyle, isOffline, StyleUtils], ); const renderItem = ({item}: {item: ToggleSettingOptionRowProps}) => ( From d619c7005b901c316f1978cb93b876b25097ca53 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 11:00:38 +0300 Subject: [PATCH 045/102] default to policy owner --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 8ca60b66e10b..133ebc737aea 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -132,8 +132,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { return; } - const approver: string = personalDetails?.[member.accountID]?.login || policy.approver || ''; - console.log(approver); + const approver: string = personalDetails?.[member.accountID]?.login || policy.approver || policy.owner; Policy.setWorkspaceApprovalMode(policy.id, approver, policy.approvalMode); Navigation.goBack(); }; From eb09ea1878d00866d1c47dca9f0aa4fa5930b4f7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 11:42:21 +0300 Subject: [PATCH 046/102] memoize policy members --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 133ebc737aea..70e3b57b6e44 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -52,11 +52,9 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} const isDeletedPolicyMember = (policyMember: PolicyMember): boolean => !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); - const sections: MembersSection[] = useMemo(() => { - const sectionsArr: MembersSection[] = []; - - const policyUsersSection: MemberOption[] = []; - const approverSection: MemberOption[] = []; + const [formattedPolicyMembers, formattedApprover] = useMemo(() => { + const formattedPolicyMembers: MemberOption[] = []; + const formattedApprover: MemberOption[] = []; Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { const accountID = Number(accountIDKey); From 9ad56ccb378adbb7cec9d229b17b04a02bb036a3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 11:42:29 +0300 Subject: [PATCH 047/102] memoize policy members --- .../WorkspaceWorkflowsApproverPage.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 70e3b57b6e44..6a265ab5998f 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -103,28 +103,33 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} }; if (policy?.approver === details.login) { - approverSection.push(formattedMember); + formattedApprover.push(formattedMember); } else { - policyUsersSection.push(formattedMember); + formattedPolicyMembers.push(formattedMember); } }); + return [formattedPolicyMembers, formattedApprover]; + }, [personalDetails, policyMembers, translate, policy?.approver]); + + const sections: MembersSection[] = useMemo(() => { + const sectionsArr: MembersSection[] = []; sectionsArr.push({ title: undefined, - data: approverSection, + data: formattedApprover, shouldShow: true, indexOffset: 0, }); sectionsArr.push({ title: translate('common.all'), - data: policyUsersSection, + data: formattedPolicyMembers, shouldShow: true, - indexOffset: approverSection.length, + indexOffset: formattedApprover.length, }); return sectionsArr; - }, [personalDetails, policyMembers, searchTerm, translate, policy?.approver]); + }, [formattedPolicyMembers, formattedApprover, searchTerm]); const setPolicyApprover = (member: MemberOption) => { if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { From e91716266c9e4f856f2153f84d7e64f70cb0bd21 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 12:54:13 +0300 Subject: [PATCH 048/102] add filter --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 6a265ab5998f..0390a697a069 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,3 +1,4 @@ +import Str from 'expensify-common/lib/str'; import React, {useMemo, useState} from 'react'; import {SectionListData} from 'react-native'; import {withOnyx} from 'react-native-onyx'; From aca798a92efc20ccb25de45a1ffce04e6963c034 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 12:54:19 +0300 Subject: [PATCH 049/102] add filter --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 0390a697a069..b8c82251139b 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -16,9 +16,11 @@ import useThemeStyles from '@hooks/useThemeStyles'; import compose from '@libs/compose'; import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Log from '@libs/Log'; +import * as LoginUtils from '@libs/LoginUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; +import {parsePhoneNumber} from '@libs/PhoneNumber'; import * as UserUtils from '@libs/UserUtils'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; From f2e6310da45e4fcaab895e18079d33e4bbaab0a9 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 12:54:24 +0300 Subject: [PATCH 050/102] add filter --- .../WorkspaceWorkflowsApproverPage.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b8c82251139b..9f1c627e1a32 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -117,6 +117,23 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} const sections: MembersSection[] = useMemo(() => { const sectionsArr: MembersSection[] = []; + if (searchTerm !== '') { + const filteredOptions = [...formattedApprover, ...formattedPolicyMembers].filter((option) => { + const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); + const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); + + const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); + return isPartOfSearchTerm; + }); + return [ + { + title: undefined, + data: filteredOptions, + shouldShow: true, + }, + ]; + } + sectionsArr.push({ title: undefined, data: formattedApprover, From a3cacc277e1052949e293f565e610f121a4e4f62 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 12:59:24 +0300 Subject: [PATCH 051/102] handle empty approver --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 9f1c627e1a32..0ff25c2ef470 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -137,7 +137,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} sectionsArr.push({ title: undefined, data: formattedApprover, - shouldShow: true, + shouldShow: formattedApprover.length > 0, indexOffset: 0, }); From e8b63b32a2794d317f4eb1dc5d21ee2800a8b323 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:04:47 +0300 Subject: [PATCH 052/102] fix lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 0ff25c2ef470..aeda8c84d1e6 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,6 +1,6 @@ import Str from 'expensify-common/lib/str'; import React, {useMemo, useState} from 'react'; -import {SectionListData} from 'react-native'; +import type {SectionListData} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import Badge from '@components/Badge'; From 722ae401e21ef010d6241623a4495f782bacd46a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:04:52 +0300 Subject: [PATCH 053/102] fix lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index aeda8c84d1e6..b1d92dc69701 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -56,8 +56,8 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); const [formattedPolicyMembers, formattedApprover] = useMemo(() => { - const formattedPolicyMembers: MemberOption[] = []; - const formattedApprover: MemberOption[] = []; + const policyMemberDetails: MemberOption[] = []; + const approverDetails: MemberOption[] = []; Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { const accountID = Number(accountIDKey); From f69f94f1d1f32601324745406cfeaeae39e7b4a7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:04:58 +0300 Subject: [PATCH 054/102] fix lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b1d92dc69701..b1ea38d9fe7a 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -106,12 +106,12 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} }; if (policy?.approver === details.login) { - formattedApprover.push(formattedMember); + approverDetails.push(formattedMember); } else { - formattedPolicyMembers.push(formattedMember); + policyMemberDetails.push(formattedMember); } }); - return [formattedPolicyMembers, formattedApprover]; + return [policyMemberDetails, approverDetails]; }, [personalDetails, policyMembers, translate, policy?.approver]); const sections: MembersSection[] = useMemo(() => { From 3e66027efbe3d26c33f61c9051867e7649ea3513 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:05:03 +0300 Subject: [PATCH 055/102] fix lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b1ea38d9fe7a..891596b1d0cc 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -155,7 +155,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { return; } - const approver: string = personalDetails?.[member.accountID]?.login || policy.approver || policy.owner; + const approver: string = personalDetails?.[member.accountID]?.login ?? policy.approver ?? policy.owner; Policy.setWorkspaceApprovalMode(policy.id, approver, policy.approvalMode); Navigation.goBack(); }; From 34aa03939f710f39369b6c84a48b217a75025f16 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:15:24 +0300 Subject: [PATCH 056/102] add not found page --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 891596b1d0cc..8170d37e8cd1 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -4,6 +4,7 @@ import type {SectionListData} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import Badge from '@components/Badge'; +import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; From 9fc8ee78d1a8b155312a604a673a985add295f3e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:15:30 +0300 Subject: [PATCH 057/102] add not found page --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 8170d37e8cd1..3844ff9fd7b7 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -22,6 +22,7 @@ import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {parsePhoneNumber} from '@libs/PhoneNumber'; +import * as PolicyUtils from '@libs/PolicyUtils'; import * as UserUtils from '@libs/UserUtils'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; From baf34f52abe3fe0f1372a00d31515e2c3c4c291b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:15:36 +0300 Subject: [PATCH 058/102] add not found page --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 3844ff9fd7b7..1ff6c021ec0c 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -41,7 +41,7 @@ type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxPro type MemberOption = Omit & {accountID: number}; type MembersSection = SectionListData>; -function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails}: WorkspaceWorkflowsApproverPageProps) { +function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, isLoadingReportData = true}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; const [searchTerm, setSearchTerm] = useState(''); From 4cf6d18e6ce50893845a4efde687e1e9badb3d00 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:15:41 +0300 Subject: [PATCH 059/102] add not found page --- .../WorkspaceWorkflowsApproverPage.tsx | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 1ff6c021ec0c..9e59fe4583cd 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -167,21 +167,28 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, includeSafeAreaPaddingBottom={false} testID={WorkspaceWorkflowsApproverPage.displayName} > - - + + + + ); } From b86d2f03fb3cfc64491f8580350aded4ed919667 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:35:18 +0300 Subject: [PATCH 060/102] handle no results --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 9e59fe4583cd..b23eac90f559 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -49,11 +49,6 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const headerMessage = useMemo(() => { - const searchValue = searchTerm.trim().toLowerCase(); - return OptionsListUtils.getHeaderMessage(true, false, searchValue); - }, [translate, searchTerm, policyName]); - const isDeletedPolicyMember = (policyMember: PolicyMember): boolean => !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); From b935378f645f6bdc333b6b481884890e87de48aa Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:35:23 +0300 Subject: [PATCH 061/102] handle no results --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b23eac90f559..e76a557b539c 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -148,6 +148,10 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, return sectionsArr; }, [formattedPolicyMembers, formattedApprover, searchTerm]); + const headerMessage = useMemo(() => { + return !sections.length ? translate('workspace.common.memberNotFound') : ''; + }, [translate, sections]); + const setPolicyApprover = (member: MemberOption) => { if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { return; From caec3f64fb0719b803755e380aada71eca3d35d2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:39:37 +0300 Subject: [PATCH 062/102] fix err msg --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index e76a557b539c..24e0dbcc94d7 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -149,7 +149,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, }, [formattedPolicyMembers, formattedApprover, searchTerm]); const headerMessage = useMemo(() => { - return !sections.length ? translate('workspace.common.memberNotFound') : ''; + return !sections[0].data.length ? translate('common.noResultsFound') : ''; }, [translate, sections]); const setPolicyApprover = (member: MemberOption) => { From b4728c9a6d0c12182c6a782cef9e4ac445d5d45c Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 14:42:44 +0300 Subject: [PATCH 063/102] fix err msg --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 24e0dbcc94d7..9c2f6f3f6e63 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -149,7 +149,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, }, [formattedPolicyMembers, formattedApprover, searchTerm]); const headerMessage = useMemo(() => { - return !sections[0].data.length ? translate('common.noResultsFound') : ''; + return searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''; }, [translate, sections]); const setPolicyApprover = (member: MemberOption) => { From 6dd7feebc155aa9bc020524b35aa800b122e410b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:39:16 +0300 Subject: [PATCH 064/102] fix lint --- .../API/parameters/SetWorkspaceWorkflowsApproverParams.ts | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts diff --git a/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts b/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts deleted file mode 100644 index cf1d4a2e705b..000000000000 --- a/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type SetWorkspaceWorkflowsApproverParams = { - policyID: string; - accountID: number; -}; - -export default SetWorkspaceWorkflowsApproverParams; From 5852f2e3648a9dffa1634586600fc150cd5865d1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:39:21 +0300 Subject: [PATCH 065/102] fix lint --- src/libs/API/parameters/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index cb3376b2b28a..fc24b97ff1f3 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -148,5 +148,4 @@ export type {default as UpdateWorkspaceDescriptionParams} from './UpdateWorkspac export type {default as SetWorkspaceRequiresCategoryParams} from './SetWorkspaceRequiresCategoryParams'; export type {default as SetWorkspaceAutoReportingParams} from './SetWorkspaceAutoReportingParams'; export type {default as SetWorkspaceApprovalModeParams} from './SetWorkspaceApprovalModeParams'; -export type {default as SetWorkspaceWorkflowsApproverParams} from './SetWorkspaceWorkflowsApproverParams'; export type {default as SwitchToOldDotParams} from './SwitchToOldDotParams'; From 538cacff17073f0d7dd46ce471e40797c51e0a22 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:39:28 +0300 Subject: [PATCH 066/102] fix lint --- src/libs/actions/Policy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 5771c7ada1de..b9a2e8535b62 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -22,7 +22,6 @@ import type { OpenWorkspaceReimburseViewParams, SetWorkspaceApprovalModeParams, SetWorkspaceAutoReportingParams, - SetWorkspaceWorkflowsApproverParams, UpdateWorkspaceAvatarParams, UpdateWorkspaceCustomUnitAndRateParams, UpdateWorkspaceDescriptionParams, From eceef704fe6e9a292dd9c7b54bd972f1fd286b29 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:47:24 +0300 Subject: [PATCH 067/102] fix lint --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 9c2f6f3f6e63..b40280c0453b 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -19,7 +19,6 @@ import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Log from '@libs/Log'; import * as LoginUtils from '@libs/LoginUtils'; import Navigation from '@libs/Navigation/Navigation'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {parsePhoneNumber} from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; From c5daa84cdb0a8c6bc94f3f6e0ca7f1307c57a1e2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:47:29 +0300 Subject: [PATCH 068/102] fix lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b40280c0453b..ebf66de553a9 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -147,9 +147,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, return sectionsArr; }, [formattedPolicyMembers, formattedApprover, searchTerm]); - const headerMessage = useMemo(() => { - return searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''; - }, [translate, sections]); + const headerMessage = useMemo(() => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), [translate, sections]); const setPolicyApprover = (member: MemberOption) => { if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { From 461d38bc2fc923626dc4436f4485789413b59329 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:57:08 +0300 Subject: [PATCH 069/102] fix more lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index ebf66de553a9..f212423ec7bb 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -23,13 +23,13 @@ import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {parsePhoneNumber} from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as UserUtils from '@libs/UserUtils'; +import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading'; +import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PersonalDetailsList, PolicyMember} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; -import withPolicyAndFullscreenLoading from '../withPolicyAndFullscreenLoading'; -import type {WithPolicyAndFullscreenLoadingProps} from '../withPolicyAndFullscreenLoading'; type WorkspaceWorkflowsApproverPageOnyxProps = { /** All of the personal details for everyone */ From b965a33c7e3823af858b8619887455ed31bd968b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:57:29 +0300 Subject: [PATCH 070/102] fix deps arr for memo --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index f212423ec7bb..4cbdedc2be2d 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -145,7 +145,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, }); return sectionsArr; - }, [formattedPolicyMembers, formattedApprover, searchTerm]); + }, [formattedPolicyMembers, formattedApprover, searchTerm, translate]); const headerMessage = useMemo(() => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), [translate, sections]); From 3f0f86bb5d8e01123d3d42afb5c2428ccb2ba40e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 00:27:43 +0300 Subject: [PATCH 071/102] rename sections array --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 4cbdedc2be2d..6c282d5c8d3e 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -111,7 +111,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, }, [personalDetails, policyMembers, translate, policy?.approver]); const sections: MembersSection[] = useMemo(() => { - const sectionsArr: MembersSection[] = []; + const sectionsArray: MembersSection[] = []; if (searchTerm !== '') { const filteredOptions = [...formattedApprover, ...formattedPolicyMembers].filter((option) => { From 784ef760bf5f5bae5de70e10242d53f795750948 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 00:27:48 +0300 Subject: [PATCH 072/102] rename sections array --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 6c282d5c8d3e..a668787a4775 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -130,21 +130,21 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, ]; } - sectionsArr.push({ + sectionsArray.push({ title: undefined, data: formattedApprover, shouldShow: formattedApprover.length > 0, indexOffset: 0, }); - sectionsArr.push({ + sectionsArray.push({ title: translate('common.all'), data: formattedPolicyMembers, shouldShow: true, indexOffset: formattedApprover.length, }); - return sectionsArr; + return sectionsArray; }, [formattedPolicyMembers, formattedApprover, searchTerm, translate]); const headerMessage = useMemo(() => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), [translate, sections]); From 91f53696c5560c3ea0d2e94f18d46dbfa71b5cbe Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 00:31:04 +0300 Subject: [PATCH 073/102] fix deps arr --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index a668787a4775..66a595aaad87 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -108,7 +108,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, } }); return [policyMemberDetails, approverDetails]; - }, [personalDetails, policyMembers, translate, policy?.approver]); + }, [personalDetails, policyMembers, translate, policy?.approver, StyleUtils, isDeletedPolicyMember, policy?.owner, styles]); const sections: MembersSection[] = useMemo(() => { const sectionsArray: MembersSection[] = []; From 8582f292016075e957b967f4fa6c1bc6d33ee464 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 00:46:13 +0300 Subject: [PATCH 074/102] rm unused --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index afcf7351f219..282ddedd650f 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -11,9 +11,7 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; -import * as ReportUtils from '@libs/ReportUtils'; import type {CentralPaneNavigatorParamList} from '@navigation/types'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; From 75e19460ba6b9989c0c9428741b8e0f59cd28591 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:22:37 +0300 Subject: [PATCH 075/102] show approver display name --- src/libs/PersonalDetailsUtils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index 55aee10e611a..a1de0945c4c1 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -56,6 +56,10 @@ function getPersonalDetailsByIDs(accountIDs: number[], currentUserAccountID: num return result; } +function getPersonalDetailByEmail(email: string): PersonalDetails | undefined { + return Object.entries(allPersonalDetails ?? {}).find(([_, detail]) => detail?.login === email) as unknown as PersonalDetails; +} + /** * Given a list of logins, find the associated personal detail and return related accountIDs. * From e717feac0e225b9e50dadf70b5bddbe7d32b09ac Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:22:44 +0300 Subject: [PATCH 076/102] show approver display name --- src/libs/PersonalDetailsUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index a1de0945c4c1..f2a375ce5ab8 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -267,6 +267,7 @@ export { isPersonalDetailsEmpty, getDisplayNameOrDefault, getPersonalDetailsByIDs, + getPersonalDetailByEmail, getAccountIDsByLogins, getLoginsByAccountIDs, getNewPersonalDetailsOnyxData, From 2201a274985f60b2b064de6e30b2477a2df2c6ba Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:22:48 +0300 Subject: [PATCH 077/102] show approver display name --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 282ddedd650f..253bb5073dee 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -11,6 +11,7 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; +import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import type {CentralPaneNavigatorParamList} from '@navigation/types'; import withPolicy from '@pages/workspace/withPolicy'; From da7246721edf546dbb1503bb94f28b9ae788b8ed Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:22:54 +0300 Subject: [PATCH 078/102] show approver display name --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 253bb5073dee..55e310db668f 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -33,7 +33,8 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { const {isSmallScreenWidth} = useWindowDimensions(); const {isOffline} = useNetwork(); - const policyApprover = policy?.approver; + const policyApproverEmail = policy?.approver; + const policyApproverName = useMemo(() => PersonalDetailsUtils.getPersonalDetailByEmail(policyApproverEmail ?? '')?.displayName || policyApproverEmail, [policyApproverEmail]); const containerStyle = useMemo(() => [styles.ph8, styles.mhn8, styles.ml11, styles.pv3, styles.pr0, styles.pl4, styles.mr0, styles.widthAuto, styles.mt4], [styles]); const items: ToggleSettingOptionRowProps[] = useMemo( From b00f2c7b916d857479faa5a9a723b11aa33435ee Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:23:01 +0300 Subject: [PATCH 079/102] show approver display name --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 55e310db668f..93719ab4130d 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -74,7 +74,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { title={translate('workflowsPage.approver')} titleStyle={styles.textLabelSupportingNormal} descriptionTextStyle={styles.textNormalThemeText} - description={policyApprover ?? ''} + description={policyApproverName ?? ''} onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVER.getRoute(route.params.policyID))} // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon From fd23672aa01098f43a84103aee7b611ff37bbc6d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:23:05 +0300 Subject: [PATCH 080/102] show approver display name --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 93719ab4130d..0219efddd97d 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -109,7 +109,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { isActive: false, // TODO will be done in https://github.com/Expensify/Expensify/issues/368335 }, ], - [policy, route.params.policyID, styles, translate, policyApprover, containerStyle, isOffline, StyleUtils], + [policy, route.params.policyID, styles, translate, policyApproverName, containerStyle, isOffline, StyleUtils], ); const renderItem = ({item}: {item: ToggleSettingOptionRowProps}) => ( From e08f21791e7ea9004e9e7629fdb743ddbff29292 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:38:24 +0300 Subject: [PATCH 081/102] fix func --- src/libs/PersonalDetailsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index f2a375ce5ab8..30d0bab9fb35 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -57,7 +57,7 @@ function getPersonalDetailsByIDs(accountIDs: number[], currentUserAccountID: num } function getPersonalDetailByEmail(email: string): PersonalDetails | undefined { - return Object.entries(allPersonalDetails ?? {}).find(([_, detail]) => detail?.login === email) as unknown as PersonalDetails; + return Object.values(allPersonalDetails ?? {}).find((detail) => detail?.login === email) as unknown as PersonalDetails; } /** From 01b12a5b4c40e26f859229543f8e15ff17605e49 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 17:42:54 +0300 Subject: [PATCH 082/102] fix center pane refresh bug --- src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index 7e38ed99105e..618eddc9f62c 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -5,6 +5,7 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = [SCREENS.WORKSPACE.PROFILE]: [SCREENS.WORKSPACE.NAME, SCREENS.WORKSPACE.CURRENCY, SCREENS.WORKSPACE.DESCRIPTION, SCREENS.WORKSPACE.SHARE], [SCREENS.WORKSPACE.REIMBURSE]: [SCREENS.WORKSPACE.RATE_AND_UNIT, SCREENS.WORKSPACE.RATE_AND_UNIT_RATE, SCREENS.WORKSPACE.RATE_AND_UNIT_UNIT], [SCREENS.WORKSPACE.MEMBERS]: [SCREENS.WORKSPACE.INVITE, SCREENS.WORKSPACE.INVITE_MESSAGE], + [SCREENS.WORKSPACE.WORKFLOWS]: [SCREENS.WORKSPACE.WORKFLOWS_APPROVER], }; export default CENTRAL_PANE_TO_RHP_MAPPING; From 675d514ac188135a5d548dc5c0cb75d5e25eb64a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 17:45:31 +0300 Subject: [PATCH 083/102] fix center pane refresh bug --- src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index 618eddc9f62c..7e38ed99105e 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -5,7 +5,6 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = [SCREENS.WORKSPACE.PROFILE]: [SCREENS.WORKSPACE.NAME, SCREENS.WORKSPACE.CURRENCY, SCREENS.WORKSPACE.DESCRIPTION, SCREENS.WORKSPACE.SHARE], [SCREENS.WORKSPACE.REIMBURSE]: [SCREENS.WORKSPACE.RATE_AND_UNIT, SCREENS.WORKSPACE.RATE_AND_UNIT_RATE, SCREENS.WORKSPACE.RATE_AND_UNIT_UNIT], [SCREENS.WORKSPACE.MEMBERS]: [SCREENS.WORKSPACE.INVITE, SCREENS.WORKSPACE.INVITE_MESSAGE], - [SCREENS.WORKSPACE.WORKFLOWS]: [SCREENS.WORKSPACE.WORKFLOWS_APPROVER], }; export default CENTRAL_PANE_TO_RHP_MAPPING; From 98f1b1ad908bc8369a04c0a73d59680c3d1282f6 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 17:46:05 +0300 Subject: [PATCH 084/102] fix center pane refresh bug --- src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index 7e38ed99105e..618eddc9f62c 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -5,6 +5,7 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = [SCREENS.WORKSPACE.PROFILE]: [SCREENS.WORKSPACE.NAME, SCREENS.WORKSPACE.CURRENCY, SCREENS.WORKSPACE.DESCRIPTION, SCREENS.WORKSPACE.SHARE], [SCREENS.WORKSPACE.REIMBURSE]: [SCREENS.WORKSPACE.RATE_AND_UNIT, SCREENS.WORKSPACE.RATE_AND_UNIT_RATE, SCREENS.WORKSPACE.RATE_AND_UNIT_UNIT], [SCREENS.WORKSPACE.MEMBERS]: [SCREENS.WORKSPACE.INVITE, SCREENS.WORKSPACE.INVITE_MESSAGE], + [SCREENS.WORKSPACE.WORKFLOWS]: [SCREENS.WORKSPACE.WORKFLOWS_APPROVER], }; export default CENTRAL_PANE_TO_RHP_MAPPING; From 4b2ccaf304300f35f2685bdb902e95d55bbeae96 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 18:23:25 +0300 Subject: [PATCH 085/102] rm todo --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 6c98ef406cf9..e5cbc9119dca 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -98,7 +98,6 @@ function WorkspaceWorkflowsPage({policy, betas, route}: WorkspaceWorkflowsPagePr descriptionTextStyle={styles.textNormalThemeText} description={policyApproverName ?? ''} onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVER.getRoute(route.params.policyID))} - // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon wrapperStyle={containerStyle} hoverAndPressStyle={[styles.mr0, styles.br2]} From 740c93ff27cfa636fb2c804dff74501c78b216e4 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 18:25:53 +0300 Subject: [PATCH 086/102] cleanup type --- src/libs/PersonalDetailsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index 1e1f1a14e861..4be9ad81184b 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -57,7 +57,7 @@ function getPersonalDetailsByIDs(accountIDs: number[], currentUserAccountID: num } function getPersonalDetailByEmail(email: string): PersonalDetails | undefined { - return Object.values(allPersonalDetails ?? {}).find((detail) => detail?.login === email) as unknown as PersonalDetails; + return (Object.values(allPersonalDetails ?? {}) as PersonalDetails[]).find((detail) => detail?.login === email); } /** From 511a5ffc93e9afea65070e727d7df59093f10a40 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 18:50:01 +0300 Subject: [PATCH 087/102] cleanup using optional chain --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 66a595aaad87..a0226965d5b6 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -150,7 +150,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, const headerMessage = useMemo(() => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), [translate, sections]); const setPolicyApprover = (member: MemberOption) => { - if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { + if (!policy?.approvalMode || !personalDetails?.[member.accountID]?.login) { return; } const approver: string = personalDetails?.[member.accountID]?.login ?? policy.approver ?? policy.owner; From 86e3c777e2c216dad3090f4bbb58d5c7884298d5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 18:58:23 +0300 Subject: [PATCH 088/102] cleanup --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index a0226965d5b6..6bc4dedb9d09 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -118,8 +118,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); - const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); - return isPartOfSearchTerm; + return !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); }); return [ { From 73cb58ce16dc1aefbd2095ade186b1860d69f00a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 19:07:39 +0300 Subject: [PATCH 089/102] fix lint --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index e5cbc9119dca..dbfb114586a1 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -46,7 +46,7 @@ function WorkspaceWorkflowsPage({policy, betas, route}: WorkspaceWorkflowsPagePr const {isOffline} = useNetwork(); const policyApproverEmail = policy?.approver; - const policyApproverName = useMemo(() => PersonalDetailsUtils.getPersonalDetailByEmail(policyApproverEmail ?? '')?.displayName || policyApproverEmail, [policyApproverEmail]); + const policyApproverName = useMemo(() => PersonalDetailsUtils.getPersonalDetailByEmail(policyApproverEmail ?? '')?.displayName ?? policyApproverEmail, [policyApproverEmail]); const containerStyle = useMemo(() => [styles.ph8, styles.mhn8, styles.ml11, styles.pv3, styles.pr0, styles.pl4, styles.mr0, styles.widthAuto, styles.mt4], [styles]); const canUseDelayedSubmission = Permissions.canUseWorkflowsDelayedSubmission(betas); From 07e69d183499e9f32285115af6b878d183d0705d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 19:08:09 +0300 Subject: [PATCH 090/102] rm unused --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index dbfb114586a1..0d8b1d2aced2 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -13,7 +13,6 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; import Permissions from '@libs/Permissions'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; From 66e81e6634b579c4938a465289217ea3e49da316 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:15:39 +0300 Subject: [PATCH 091/102] dry parse phone --- src/libs/PhoneNumber.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/PhoneNumber.ts b/src/libs/PhoneNumber.ts index 787b3634030a..532fbf305fd3 100644 --- a/src/libs/PhoneNumber.ts +++ b/src/libs/PhoneNumber.ts @@ -2,6 +2,7 @@ import {parsePhoneNumber as originalParsePhoneNumber} from 'awesome-phonenumber'; import type {ParsedPhoneNumber, ParsedPhoneNumberInvalid, PhoneNumberParseOptions} from 'awesome-phonenumber'; import Str from 'expensify-common/lib/str'; +import * as LoginUtils from '@libs/LoginUtils'; import CONST from '@src/CONST'; /** From 449e7a6ce810c67fd249c3c33dde8c70be391bc3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:15:44 +0300 Subject: [PATCH 092/102] dry parse phone --- src/libs/PhoneNumber.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/PhoneNumber.ts b/src/libs/PhoneNumber.ts index 532fbf305fd3..2e793695b523 100644 --- a/src/libs/PhoneNumber.ts +++ b/src/libs/PhoneNumber.ts @@ -52,5 +52,10 @@ function addSMSDomainIfPhoneNumber(login: string): string { return login; } +function getSearchValueForPhoneOrEmail(searchTerm: string) { + const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); + return parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); +} + // eslint-disable-next-line import/prefer-default-export -export {parsePhoneNumber, addSMSDomainIfPhoneNumber}; +export {parsePhoneNumber, addSMSDomainIfPhoneNumber, getSearchValueForPhoneOrEmail}; From 74591dca74949a2246476b9f5b74315d0273cb69 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:15:49 +0300 Subject: [PATCH 093/102] dry parse phone --- src/pages/workspace/WorkspaceInvitePage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceInvitePage.tsx b/src/pages/workspace/WorkspaceInvitePage.tsx index 03fa78367eda..c4db248af108 100644 --- a/src/pages/workspace/WorkspaceInvitePage.tsx +++ b/src/pages/workspace/WorkspaceInvitePage.tsx @@ -176,8 +176,8 @@ function WorkspaceInvitePage({ filterSelectedOptions = selectedOptions.filter((option) => { const accountID = option.accountID; const isOptionInPersonalDetails = Object.values(personalDetails).some((personalDetail) => personalDetail.accountID === accountID); - const parsedPhoneNumber = PhoneNumber.parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); - const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); + + const searchValue = PhoneNumber.getSearchValueForPhoneOrEmail(searchTerm); const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); return isPartOfSearchTerm || isOptionInPersonalDetails; From 8c74efcad8411fb2d354b02dbe8dd8f3ee5a81d3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:15:55 +0300 Subject: [PATCH 094/102] dry parse phone --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 6bc4dedb9d09..c316beb27bda 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -20,7 +20,7 @@ import Log from '@libs/Log'; import * as LoginUtils from '@libs/LoginUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; -import {parsePhoneNumber} from '@libs/PhoneNumber'; +import {getSearchValueForPhoneOrEmail} from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as UserUtils from '@libs/UserUtils'; import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading'; From d4b03448f648cf979e2526d64c6a11d0c1b35480 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:15:59 +0300 Subject: [PATCH 095/102] dry parse phone --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index c316beb27bda..42b03e12dcee 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -115,9 +115,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, if (searchTerm !== '') { const filteredOptions = [...formattedApprover, ...formattedPolicyMembers].filter((option) => { - const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); - const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); - + const searchValue = getSearchValueForPhoneOrEmail(searchTerm); return !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); }); return [ From 5c6423c257fa58407a2efbc9bdc18c2b09a2221a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:37:23 +0300 Subject: [PATCH 096/102] fix lint --- src/libs/PhoneNumber.ts | 2 +- src/pages/workspace/WorkspaceInvitePage.tsx | 1 - .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libs/PhoneNumber.ts b/src/libs/PhoneNumber.ts index 2e793695b523..6ed96fde304d 100644 --- a/src/libs/PhoneNumber.ts +++ b/src/libs/PhoneNumber.ts @@ -2,8 +2,8 @@ import {parsePhoneNumber as originalParsePhoneNumber} from 'awesome-phonenumber'; import type {ParsedPhoneNumber, ParsedPhoneNumberInvalid, PhoneNumberParseOptions} from 'awesome-phonenumber'; import Str from 'expensify-common/lib/str'; -import * as LoginUtils from '@libs/LoginUtils'; import CONST from '@src/CONST'; +import * as LoginUtils from './LoginUtils'; /** * Wraps awesome-phonenumber's parsePhoneNumber function to handle the case where we want to treat diff --git a/src/pages/workspace/WorkspaceInvitePage.tsx b/src/pages/workspace/WorkspaceInvitePage.tsx index c4db248af108..0813acd8b5a4 100644 --- a/src/pages/workspace/WorkspaceInvitePage.tsx +++ b/src/pages/workspace/WorkspaceInvitePage.tsx @@ -1,6 +1,5 @@ import {useNavigation} from '@react-navigation/native'; import type {StackNavigationProp, StackScreenProps} from '@react-navigation/stack'; -import Str from 'expensify-common/lib/str'; import React, {useEffect, useMemo, useState} from 'react'; import type {SectionListData} from 'react-native'; import {View} from 'react-native'; diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 42b03e12dcee..fd223e25ca46 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,4 +1,3 @@ -import Str from 'expensify-common/lib/str'; import React, {useMemo, useState} from 'react'; import type {SectionListData} from 'react-native'; import {withOnyx} from 'react-native-onyx'; @@ -17,7 +16,6 @@ import useThemeStyles from '@hooks/useThemeStyles'; import compose from '@libs/compose'; import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Log from '@libs/Log'; -import * as LoginUtils from '@libs/LoginUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {getSearchValueForPhoneOrEmail} from '@libs/PhoneNumber'; From 1c9866003a5aacc54ebb5fc605360be54e5f53d0 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:50:49 +0300 Subject: [PATCH 097/102] fix deps cycle --- src/libs/OptionsListUtils.ts | 6 ++++++ src/libs/PhoneNumber.ts | 8 +------- src/pages/workspace/WorkspaceInvitePage.tsx | 2 +- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 91fce003d19e..89a087005cff 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -785,6 +785,11 @@ function getEnabledCategoriesCount(options: PolicyCategories): number { return Object.values(options).filter((option) => option.enabled).length; } +function getSearchValueForPhoneOrEmail(searchTerm: string) { + const parsedPhoneNumber = PhoneNumber.parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); + return parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); +} + /** * Verifies that there is at least one enabled option */ @@ -2007,6 +2012,7 @@ export { getMemberInviteOptions, getHeaderMessage, getHeaderMessageForNonUserList, + getSearchValueForPhoneOrEmail, getPersonalDetailsForAccountIDs, getIOUConfirmationOptionsFromPayeePersonalDetail, getIOUConfirmationOptionsFromParticipants, diff --git a/src/libs/PhoneNumber.ts b/src/libs/PhoneNumber.ts index 6ed96fde304d..787b3634030a 100644 --- a/src/libs/PhoneNumber.ts +++ b/src/libs/PhoneNumber.ts @@ -3,7 +3,6 @@ import {parsePhoneNumber as originalParsePhoneNumber} from 'awesome-phonenumber' import type {ParsedPhoneNumber, ParsedPhoneNumberInvalid, PhoneNumberParseOptions} from 'awesome-phonenumber'; import Str from 'expensify-common/lib/str'; import CONST from '@src/CONST'; -import * as LoginUtils from './LoginUtils'; /** * Wraps awesome-phonenumber's parsePhoneNumber function to handle the case where we want to treat @@ -52,10 +51,5 @@ function addSMSDomainIfPhoneNumber(login: string): string { return login; } -function getSearchValueForPhoneOrEmail(searchTerm: string) { - const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); - return parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); -} - // eslint-disable-next-line import/prefer-default-export -export {parsePhoneNumber, addSMSDomainIfPhoneNumber, getSearchValueForPhoneOrEmail}; +export {parsePhoneNumber, addSMSDomainIfPhoneNumber}; diff --git a/src/pages/workspace/WorkspaceInvitePage.tsx b/src/pages/workspace/WorkspaceInvitePage.tsx index 0813acd8b5a4..67bf6f8064da 100644 --- a/src/pages/workspace/WorkspaceInvitePage.tsx +++ b/src/pages/workspace/WorkspaceInvitePage.tsx @@ -176,7 +176,7 @@ function WorkspaceInvitePage({ const accountID = option.accountID; const isOptionInPersonalDetails = Object.values(personalDetails).some((personalDetail) => personalDetail.accountID === accountID); - const searchValue = PhoneNumber.getSearchValueForPhoneOrEmail(searchTerm); + const searchValue = OptionsListUtils.getSearchValueForPhoneOrEmail(searchTerm); const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); return isPartOfSearchTerm || isOptionInPersonalDetails; diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index fd223e25ca46..b64d752d228e 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -17,8 +17,8 @@ import compose from '@libs/compose'; import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; -import {getSearchValueForPhoneOrEmail} from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as UserUtils from '@libs/UserUtils'; import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading'; @@ -113,7 +113,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, if (searchTerm !== '') { const filteredOptions = [...formattedApprover, ...formattedPolicyMembers].filter((option) => { - const searchValue = getSearchValueForPhoneOrEmail(searchTerm); + const searchValue = OptionsListUtils.getSearchValueForPhoneOrEmail(searchTerm); return !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); }); return [ From 25a5b0ffd57d52bfdc36467d3e8c57d20ad029f6 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 21:11:43 +0300 Subject: [PATCH 098/102] memoize deletedpolicy member --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b64d752d228e..f163913ce4d6 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,4 +1,4 @@ -import React, {useMemo, useState} from 'react'; +import React, {useCallback, useMemo, useState} from 'react'; import type {SectionListData} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; @@ -46,8 +46,10 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const isDeletedPolicyMember = (policyMember: PolicyMember): boolean => - !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); + const isDeletedPolicyMember = useCallback( + (policyMember: PolicyMember) => !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors), + [isOffline], + ); const [formattedPolicyMembers, formattedApprover] = useMemo(() => { const policyMemberDetails: MemberOption[] = []; From 47738f60023ab3deed7df35a3f60f43c7943b860 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 21:28:52 +0300 Subject: [PATCH 099/102] fix lint --- src/libs/Navigation/types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 6d680ac7e190..a1e558869ebe 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -63,6 +63,9 @@ type CentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.WORKFLOWS]: { policyID: string; }; + [SCREENS.WORKSPACE.WORKFLOWS_APPROVER]: { + policyID: string; + }; [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: { policyID: string; }; From e60a960b7b5a49b57ff93e1c98e46ac7a23e93d3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 21:34:14 +0300 Subject: [PATCH 100/102] ignore deps rule --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index f163913ce4d6..93128ea8e953 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -144,7 +144,11 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, return sectionsArray; }, [formattedPolicyMembers, formattedApprover, searchTerm, translate]); - const headerMessage = useMemo(() => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), [translate, sections]); + const headerMessage = useMemo( + () => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), + //eslint-disable-next-line react-hooks/exhaustive-deps + [translate, sections], + ); const setPolicyApprover = (member: MemberOption) => { if (!policy?.approvalMode || !personalDetails?.[member.accountID]?.login) { From 8b0d41722fa05b0931f3c817b2552782fd83596e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 21:40:46 +0300 Subject: [PATCH 101/102] ignore deps rule --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 93128ea8e953..692a24ee2c66 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -144,11 +144,11 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, return sectionsArray; }, [formattedPolicyMembers, formattedApprover, searchTerm, translate]); - const headerMessage = useMemo( - () => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), + const headerMessage = useMemo(() => { + return searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''; + //eslint-disable-next-line react-hooks/exhaustive-deps - [translate, sections], - ); + }, [translate, sections]); const setPolicyApprover = (member: MemberOption) => { if (!policy?.approvalMode || !personalDetails?.[member.accountID]?.login) { From 45585e82d907f4bcd1b58b0fd6003286a75974d1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 21:46:28 +0300 Subject: [PATCH 102/102] ignore deps rule --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 692a24ee2c66..52406a8033d2 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -144,11 +144,12 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, return sectionsArray; }, [formattedPolicyMembers, formattedApprover, searchTerm, translate]); - const headerMessage = useMemo(() => { - return searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''; + const headerMessage = useMemo( + () => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), - //eslint-disable-next-line react-hooks/exhaustive-deps - }, [translate, sections]); + // eslint-disable-next-line react-hooks/exhaustive-deps + [translate, sections], + ); const setPolicyApprover = (member: MemberOption) => { if (!policy?.approvalMode || !personalDetails?.[member.accountID]?.login) {