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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ const translations: TranslationDeepObject<typeof en> = {
vacationDelegate: 'Urlaubsvertretung',
expensifyLogo: 'Expensify-Logo',
duplicateReport: 'Duplizierten Bericht',
approver: 'Genehmiger',
},
socials: {
podcast: 'Folgen Sie uns auf Podcast',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ const translations = {
quarter: 'Quarter',
vacationDelegate: 'Vacation delegate',
expensifyLogo: 'Expensify logo',
approver: 'Approver',
},
socials: {
podcast: 'Follow us on Podcast',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ const translations: TranslationDeepObject<typeof en> = {
quarter: 'Trimestre',
vacationDelegate: 'Delegado de vacaciones',
expensifyLogo: 'Logo de Expensify',
approver: 'Aprobador',
},
socials: {
podcast: 'Síguenos en Podcast',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ const translations: TranslationDeepObject<typeof en> = {
vacationDelegate: 'Délégué de vacances',
expensifyLogo: 'Logo Expensify',
duplicateReport: 'Note de frais en double',
approver: 'Approbateur',
},
socials: {
podcast: 'Suivez-nous sur Podcast',
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ const translations: TranslationDeepObject<typeof en> = {
vacationDelegate: 'Delega ferie',
expensifyLogo: 'Logo Expensify',
duplicateReport: 'Report duplicato',
approver: 'Approvante',
},
socials: {
podcast: 'Seguici su Podcast',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ const translations: TranslationDeepObject<typeof en> = {
vacationDelegate: '休暇代理人',
expensifyLogo: 'Expensifyロゴ',
duplicateReport: 'レポートを複製',
approver: '承認者',
},
socials: {
podcast: 'ポッドキャストでフォロー',
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ const translations: TranslationDeepObject<typeof en> = {
vacationDelegate: 'Vertegenwoordiger tijdens vakantie',
expensifyLogo: 'Expensify-logo',
duplicateReport: 'Dubbel rapport',
approver: 'Fiatteur',
},
socials: {
podcast: 'Volg ons op Podcast',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ const translations: TranslationDeepObject<typeof en> = {
vacationDelegate: 'Zastępca urlopowy',
expensifyLogo: 'Logo Expensify',
duplicateReport: 'Zduplikowany raport',
approver: 'Osoba zatwierdzająca',
},
socials: {
podcast: 'Śledź nas na Podcast',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ const translations: TranslationDeepObject<typeof en> = {
vacationDelegate: 'Delegado de férias',
expensifyLogo: 'Logo da Expensify',
duplicateReport: 'Duplicar relatório',
approver: 'Aprovador',
},
socials: {
podcast: 'Siga-nos no Podcast',
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ const translations: TranslationDeepObject<typeof en> = {
vacationDelegate: '休假代理',
expensifyLogo: 'Expensify徽标',
duplicateReport: '重复报销单',
approver: '审批人',
},
socials: {
podcast: '在播客上关注我们',
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Policy/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,7 @@ function setPolicyCategoryApprover(policyID: string, categoryName: string, appro
],
});
} else if (existingCategoryApproverRule?.approver === approver) {
updatedApprovalRules = updatedApprovalRules.filter((rule) => rule.approver !== approver);
updatedApprovalRules = updatedApprovalRules.filter((rule) => rule !== existingCategoryApproverRule);
newApprover = '';
} else {
const indexToUpdate = updatedApprovalRules.indexOf(existingCategoryApproverRule);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Policy/Tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ function setPolicyTagApprover(policy: OnyxEntry<Policy>, tag: string, approver:
const policyID = policy.id;
const prevApprovalRules = policy?.rules?.approvalRules ?? [];
const approverRuleToUpdate = PolicyUtils.getTagApproverRule(policy, tag);
const filteredApprovalRules = approverRuleToUpdate ? prevApprovalRules.filter((rule) => rule.id !== approverRuleToUpdate.id) : prevApprovalRules;
const filteredApprovalRules = approverRuleToUpdate ? prevApprovalRules.filter((rule) => rule !== approverRuleToUpdate) : prevApprovalRules;
const toBeUnselected = approverRuleToUpdate?.approver === approver;

const updatedApproverRule = approverRuleToUpdate
Expand Down
56 changes: 53 additions & 3 deletions src/pages/workspace/categories/WorkspaceCategoriesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {InteractionManager, View} from 'react-native';
import ActivityIndicator from '@components/ActivityIndicator';
import Avatar from '@components/Avatar';
import Button from '@components/Button';
import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu';
import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types';
Expand Down Expand Up @@ -39,12 +40,14 @@ import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import {isConnectionInProgress, isConnectionUnverified} from '@libs/actions/connections';
import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import {getDecodedCategoryName} from '@libs/CategoryUtils';
import {getCategoryApproverRule, getDecodedCategoryName} from '@libs/CategoryUtils';
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
import {formatPhoneNumber} from '@libs/LocalePhoneNumber';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types';
import {isDisablingOrDeletingLastEnabledCategory} from '@libs/OptionsListUtils';
import {getPersonalDetailByEmail} from '@libs/PersonalDetailsUtils';
import {getConnectedIntegration, getCurrentConnectionName, hasAccountingConnections, hasTags, isControlPolicy, shouldShowSyncError} from '@libs/PolicyUtils';
import tokenizedSearch from '@libs/tokenizedSearch';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
Expand Down Expand Up @@ -89,6 +92,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
const [selectedCategories, setSelectedCategories] = useState<string[]>([]);
const canSelectMultiple = isSmallScreenWidth ? isMobileSelectionModeEnabled : true;
const isControlPolicyWithWideLayout = !shouldUseNarrowLayout && isControlPolicy(policy);
const shouldShowApproverColumn = isControlPolicyWithWideLayout && !!policy?.areRulesEnabled;
const icons = useMemoizedLazyExpensifyIcons(['Checkmark', 'Close', 'Download', 'Gear', 'Plus', 'Table', 'Trashcan'] as const);
const illustrations = useMemoizedLazyIllustrations(['FolderOpen']);

Expand Down Expand Up @@ -208,6 +212,11 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
return acc;
}

const approverEmail = shouldShowApproverColumn ? (getCategoryApproverRule(policy?.rules?.approvalRules ?? [], value.name)?.approver ?? '') : '';
const approverPersonalDetail = getPersonalDetailByEmail(approverEmail);
const {avatar, displayName = approverEmail, accountID} = approverPersonalDetail ?? {};
const approverDisplayName = displayName ? formatPhoneNumber(displayName) : '';

acc.push({
text: getDecodedCategoryName(value.name),
keyForList: value.name,
Expand All @@ -224,6 +233,28 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
{value['GL Code']}
</Text>
</View>
{shouldShowApproverColumn && (
<View style={[glCodeContainerStyle, styles.flexRow, styles.alignItemsCenter]}>
{approverDisplayName ? (
<>
<Avatar
source={avatar}
name={approverDisplayName}
avatarID={accountID}
type={CONST.ICON_TYPE_AVATAR}
size={CONST.AVATAR_SIZE.SUBSCRIPT}
containerStyles={[styles.mr3]}
/>
<Text
numberOfLines={1}
style={glCodeTextStyle}
>
{approverDisplayName}
</Text>
</>
) : null}
</View>
)}
<View style={switchContainerStyle}>
<Switch
isOn={value.enabled}
Expand Down Expand Up @@ -259,7 +290,21 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {

return acc;
}, []);
}, [policyCategories, isOffline, translate, updateWorkspaceCategoryEnabled, policy, isControlPolicyWithWideLayout, glCodeContainerStyle, glCodeTextStyle, switchContainerStyle]);
}, [
policyCategories,
isOffline,
translate,
updateWorkspaceCategoryEnabled,
policy,
isControlPolicyWithWideLayout,
glCodeContainerStyle,
glCodeTextStyle,
switchContainerStyle,
shouldShowApproverColumn,
styles.alignItemsCenter,
styles.flexRow,
styles.mr3,
]);

const filterCategory = useCallback((categoryOption: ListItem, searchInput: string) => {
const results = tokenizedSearch([categoryOption], searchInput, (option) => [option.text ?? '', option.alternateText ?? '']);
Expand Down Expand Up @@ -298,7 +343,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
return null;
}

// Show GL Code column only on wide screens for control policies
// Show GL Code column only on wide screens for control policies. Approver column additionally requires rules to be enabled
if (isControlPolicyWithWideLayout) {
return (
<View style={[styles.flex1, styles.flexRow, styles.justifyContentBetween, styles.pl3]}>
Expand All @@ -308,6 +353,11 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
<View style={[styles.flex1, styles.pr16]}>
<Text style={[styles.textMicroSupporting, styles.alignSelfStart]}>{translate('workspace.categories.glCode')}</Text>
</View>
{shouldShowApproverColumn && (
<View style={[styles.flex1, styles.pr16]}>
<Text style={[styles.textMicroSupporting, styles.alignSelfStart]}>{translate('common.approver')}</Text>
</View>
)}
<View style={[StyleUtils.getMinimumWidth(variables.w72), styles.mr5]}>
<Text style={[styles.textMicroSupporting, styles.alignSelfStart]}>{translate('common.enabled')}</Text>
</View>
Expand Down
Loading
Loading