Skip to content

Fix - Add a setting for creating a different default report title in New Expensify Collect #59568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
34d77b7
implement moving report fields into reports feature
FitseTLT Apr 2, 2025
274f2ea
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT Apr 3, 2025
cdf6f7d
clean up related to enablePolicyDefaultReportTitle
FitseTLT Apr 3, 2025
87dd972
update preventMemberChangeTitle toggle afte upgrade plan
FitseTLT Apr 3, 2025
1fadb4a
fix ts
FitseTLT Apr 3, 2025
247b3bd
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT Apr 3, 2025
b38fb30
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT Apr 4, 2025
1e4cca8
add reports menu to protectedmenuitems
FitseTLT Apr 4, 2025
9d168a4
fix styling
FitseTLT Apr 4, 2025
18475f0
fix ts
FitseTLT Apr 4, 2025
d6ed511
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT Apr 10, 2025
d24bb47
fix lint
FitseTLT Apr 10, 2025
020f9f5
remove going back when enabling report field
FitseTLT Apr 10, 2025
0a79367
added confirm modal on report field disabling
FitseTLT Apr 10, 2025
c0b758d
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT Apr 11, 2025
06b8887
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT Apr 14, 2025
541e229
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT Apr 23, 2025
819f49e
minor updates
FitseTLT Apr 23, 2025
97d7d20
minor update
FitseTLT Apr 23, 2025
b146464
minor fix
FitseTLT Apr 23, 2025
8b80b5d
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT Apr 28, 2025
bf076b5
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT Apr 30, 2025
b719e41
removed add field for no accounting connections
FitseTLT Apr 30, 2025
c19edbb
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT May 5, 2025
105ec10
re-added accounting report field info
FitseTLT May 5, 2025
ea92f2e
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT May 6, 2025
09675e5
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT May 7, 2025
6fe51c1
added confirm modal on disabling report field when there is accountin…
FitseTLT May 7, 2025
7f7e262
Merge branch 'main' into fix-move-report-fields-feature-to-reports
FitseTLT May 8, 2025
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: 0 additions & 1 deletion __mocks__/reportData/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const policy420A: Policy = {
},
areRulesEnabled: false,
eReceipts: true,
shouldShowCustomReportTitleOption: false,
shouldShowAutoApprovalOptions: false,
shouldShowAutoReimbursementLimitOption: false,
maxExpenseAmountNoReceipt: 100000,
Expand Down
7 changes: 6 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ const CONST = {
'https://help.expensify.com/articles/new-expensify/connect-credit-cards/company-cards/Commercial-feeds#how-to-set-up-an-american-express-corporate-feed',
COMPANY_CARDS_STRIPE_HELP: 'https://dashboard.stripe.com/login?redirect=%2Fexpenses%2Fsettings',
COMPANY_CARDS_CONNECT_CREDIT_CARDS_HELP_URL: 'https://help.expensify.com/new-expensify/hubs/connect-credit-cards/',
CUSTOM_REPORT_NAME_HELP_URL: 'https://help.expensify.com/articles/expensify-classic/spending-insights/Custom-Templates',
CUSTOM_REPORT_NAME_HELP_URL: 'https://help.expensify.com/articles/expensify-classic/spending-insights/Export-Expenses-And-Reports#formulas',
CONFIGURE_REIMBURSEMENT_SETTINGS_HELP_URL: 'https://help.expensify.com/articles/expensify-classic/workspaces/Configure-Reimbursement-Settings',
COPILOT_HELP_URL: 'https://help.expensify.com/articles/new-expensify/settings/Add-or-Act-As-a-Copilot',
DELAYED_SUBMISSION_HELP_URL: 'https://help.expensify.com/articles/expensify-classic/reports/Automatically-submit-employee-reports',
Expand Down Expand Up @@ -6720,6 +6720,11 @@ const CONST = {
description: 'workspace.upgrade.reportFields.description' as const,
icon: 'Pencil',
},
policyPreventMemberChangingTitle: {
id: 'policyPreventMemberChangingTitle' as const,
alias: 'policy-prevent-member-changing-title',
name: undefined,
},
categories: {
id: 'categories' as const,
alias: 'categories',
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/Illustrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ import ThreeLeggedLaptopWoman from '@assets/images/product-illustrations/three_l
import ToddBehindCloud from '@assets/images/product-illustrations/todd-behind-cloud.svg';
import ToddWithPhones from '@assets/images/product-illustrations/todd-with-phones.svg';
import RunningTurtle from '@assets/images/running-turtle.svg';
import ReportReceipt from '@assets/images/simple-illustration__report-receipt.svg';
import BigVault from '@assets/images/simple-illustrations/emptystate__big-vault.svg';
import Puzzle from '@assets/images/simple-illustrations/emptystate__puzzlepieces.svg';
import Abacus from '@assets/images/simple-illustrations/simple-illustration__abacus.svg';
Expand Down Expand Up @@ -131,6 +130,7 @@ import ReceiptEnvelope from '@assets/images/simple-illustrations/simple-illustra
import ReceiptLocationMarker from '@assets/images/simple-illustrations/simple-illustration__receipt-location-marker.svg';
import ReceiptWrangler from '@assets/images/simple-illustrations/simple-illustration__receipt-wrangler.svg';
import ReceiptUpload from '@assets/images/simple-illustrations/simple-illustration__receiptupload.svg';
import ReportReceipt from '@assets/images/simple-illustrations/simple-illustration__report-receipt.svg';
import Rules from '@assets/images/simple-illustrations/simple-illustration__rules.svg';
import SanFrancisco from '@assets/images/simple-illustrations/simple-illustration__sanfrancisco.svg';
import SendMoney from '@assets/images/simple-illustrations/simple-illustration__sendmoney.svg';
Expand Down
6 changes: 3 additions & 3 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2905,6 +2905,7 @@ const translations = {
categories: 'Categories',
tags: 'Tags',
reportFields: 'Report fields',
reportTitle: 'Report title',
reportField: 'Report field',
taxes: 'Taxes',
bills: 'Bills',
Expand Down Expand Up @@ -4922,9 +4923,8 @@ const translations = {
examples: 'Examples:',
title: 'Expense reports',
subtitle: 'Automate expense report compliance, approvals, and payment.',
customReportNamesTitle: 'Custom report names',
customReportNamesSubtitle: 'Create custom names using our extensive formulas.',
customNameTitle: 'Custom name',
customReportNamesSubtitle: 'Customize report titles using our ',
customNameTitle: 'Default report title',
customNameDescription: 'Choose a custom name for expense reports using our ',
customNameDescriptionLink: 'extensive formulas',
customNameInputLabel: 'Name',
Expand Down
6 changes: 3 additions & 3 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2931,6 +2931,7 @@ const translations = {
categories: 'Categorías',
tags: 'Etiquetas',
reportFields: 'Campos de informe',
reportTitle: 'El título del informe.',
taxes: 'Impuestos',
bills: 'Pagar facturas',
invoices: 'Facturas',
Expand Down Expand Up @@ -4994,9 +4995,8 @@ const translations = {
examples: 'Ejemplos:',
title: 'Informes de gastos',
subtitle: 'Automatiza el cumplimiento, la aprobación y el pago de los informes de gastos.',
customReportNamesTitle: 'Nombres personalizados de informes',
customReportNamesSubtitle: 'Crea nombres personalizados usando nuestras fórmulas variadas.',
customNameTitle: 'Nombre personalizado',
customReportNamesSubtitle: 'Personaliza los títulos de los informes usando nuestras amplias fórmulas.',
customNameTitle: 'Título de informe predeterminado',
customNameDescription: 'Elige un nombre personalizado para los informes de gastos usando nuestras ',
customNameDescriptionLink: 'fórmulas variadas',
customNameInputLabel: 'Nombre',
Expand Down
6 changes: 0 additions & 6 deletions src/libs/API/parameters/EnablePolicyDefaultReportTitle.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ export type {default as SetPolicyPreventMemberCreatedTitleParams} from './SetPol
export type {default as SetPolicyAutoReimbursementLimitParams} from './SetPolicyAutoReimbursementLimit';
export type {default as EnablePolicyAutoReimbursementLimitParams} from './EnablePolicyAutoReimbursementLimit';
export type {default as EnablePolicyAutoApprovalOptionsParams} from './EnablePolicyAutoApprovalOptions';
export type {default as EnablePolicyDefaultReportTitleParams} from './EnablePolicyDefaultReportTitle';
export type {default as SetPolicyExpenseMaxAmountNoReceipt} from './SetPolicyExpenseMaxAmountNoReceipt';
export type {default as SetPolicyExpenseMaxAmount} from './SetPolicyExpenseMaxAmount';
export type {default as SetPolicyExpenseMaxAge} from './SetPolicyExpenseMaxAge';
Expand Down
2 changes: 0 additions & 2 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const WRITE_COMMANDS = {
SET_POLICY_AUTO_REIMBURSEMENT_LIMIT: 'SetPolicyAutoReimbursementLimit',
ENABLE_POLICY_AUTO_REIMBURSEMENT_LIMIT: 'EnablePolicyAutoReimbursementLimit',
ENABLE_POLICY_AUTO_APPROVAL_OPTIONS: 'EnablePolicyAutoApprovalOptions',
ENABLE_POLICY_DEFAULT_REPORT_TITLE: 'EnablePolicyDefaultReportTitle',
SET_WORKSPACE_DEFAULT_SPEND_CATEGORY: 'SetPolicyDefaultSpendCategory',
DISMISS_REFERRAL_BANNER: 'DismissReferralBanner',
UPDATE_PREFERRED_LOCALE: 'UpdatePreferredLocale',
Expand Down Expand Up @@ -693,7 +692,6 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.SET_POLICY_AUTO_REIMBURSEMENT_LIMIT]: Parameters.SetPolicyAutoReimbursementLimitParams;
[WRITE_COMMANDS.ENABLE_POLICY_AUTO_REIMBURSEMENT_LIMIT]: Parameters.EnablePolicyAutoReimbursementLimitParams;
[WRITE_COMMANDS.ENABLE_POLICY_AUTO_APPROVAL_OPTIONS]: Parameters.EnablePolicyAutoApprovalOptionsParams;
[WRITE_COMMANDS.ENABLE_POLICY_DEFAULT_REPORT_TITLE]: Parameters.EnablePolicyDefaultReportTitleParams;
[WRITE_COMMANDS.SET_WORKSPACE_DEFAULT_SPEND_CATEGORY]: Parameters.SetWorkspaceDefaultSpendCategoryParams;
[WRITE_COMMANDS.SWITCH_TO_OLD_DOT]: Parameters.SwitchToOldDotParams;
[WRITE_COMMANDS.TRACK_EXPENSE]: Parameters.TrackExpenseParams;
Expand Down
81 changes: 1 addition & 80 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import type {
EnablePolicyAutoReimbursementLimitParams,
EnablePolicyCompanyCardsParams,
EnablePolicyConnectionsParams,
EnablePolicyDefaultReportTitleParams,
EnablePolicyExpensifyCardsParams,
EnablePolicyInvoicingParams,
EnablePolicyReportFieldsParams,
Expand Down Expand Up @@ -3044,7 +3043,7 @@ function enableCompanyCards(policyID: string, enabled: boolean, shouldGoBack = t
}
}

function enablePolicyReportFields(policyID: string, enabled: boolean, shouldGoBack = true) {
function enablePolicyReportFields(policyID: string, enabled: boolean) {
const onyxData: OnyxData = {
optimisticData: [
{
Expand Down Expand Up @@ -3088,10 +3087,6 @@ function enablePolicyReportFields(policyID: string, enabled: boolean, shouldGoBa
API.write(WRITE_COMMANDS.ENABLE_POLICY_REPORT_FIELDS, parameters, onyxData, {
checkAndFixConflictingRequest: (persistedRequests) => resolveEnableFeatureConflicts(WRITE_COMMANDS.ENABLE_POLICY_REPORT_FIELDS, persistedRequests, parameters),
});

if (enabled && getIsNarrowLayout() && shouldGoBack) {
goBackWhenEnableFeature(policyID);
}
}

function enablePolicyTaxes(policyID: string, enabled: boolean) {
Expand Down Expand Up @@ -4273,79 +4268,6 @@ function getAdminPoliciesConnectedToNetSuite(): Policy[] {
return Object.values(allPolicies ?? {}).filter<Policy>((policy): policy is Policy => !!policy && policy.role === CONST.POLICY.ROLE.ADMIN && !!policy?.connections?.netsuite);
}

/**
* Call the API to enable custom report title for the reports in the given policy
* @param policyID - id of the policy to apply the limit to
* @param enabled - whether custom report title for the reports is enabled in the given policy
*/
function enablePolicyDefaultReportTitle(policyID: string, enabled: boolean) {
const policy = getPolicy(policyID);

if (enabled === policy?.shouldShowCustomReportTitleOption) {
return;
}

const previousReportTitleField = policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE] ?? {};
const titleFieldValues = enabled ? {} : {fieldList: {[CONST.POLICY.FIELDS.FIELD_LIST_TITLE]: {...previousReportTitleField, defaultValue: CONST.POLICY.DEFAULT_REPORT_NAME_PATTERN}}};

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
shouldShowCustomReportTitleOption: enabled,
...titleFieldValues,
pendingFields: {
shouldShowCustomReportTitleOption: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
},
},
];

const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
pendingFields: {
shouldShowCustomReportTitleOption: null,
},
errorFields: null,
},
},
];

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
shouldShowCustomReportTitleOption: !!policy?.shouldShowCustomReportTitleOption,
fieldList: {
[CONST.POLICY.FIELDS.FIELD_LIST_TITLE]: previousReportTitleField,
},
pendingFields: {
shouldShowCustomReportTitleOption: null,
},
errorFields: {
shouldShowCustomReportTitleOption: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
},
},
},
];

const parameters: EnablePolicyDefaultReportTitleParams = {
enable: enabled,
policyID,
};

API.write(WRITE_COMMANDS.ENABLE_POLICY_DEFAULT_REPORT_TITLE, parameters, {
optimisticData,
successData,
failureData,
});
}

/**
* Call the API to set default report title pattern for the given policy
* @param policyID - id of the policy to apply the naming pattern to
Expand Down Expand Up @@ -5260,7 +5182,6 @@ export {
setPolicyAutomaticApprovalLimit,
setPolicyAutomaticApprovalRate,
setPolicyAutoReimbursementLimit,
enablePolicyDefaultReportTitle,
enablePolicyAutoReimbursementLimit,
enableAutoApprovalOptions,
setPolicyMaxExpenseAmountNoReceipt,
Expand Down
19 changes: 8 additions & 11 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import {
Car,
Coins,
CreditCard,
Document,
ExpensifyAppIcon,
ExpensifyCard,
Feed,
Folder,
Gear,
InvoiceGeneric,
Pencil,
Sync,
Tag,
Users,
Expand Down Expand Up @@ -177,6 +177,13 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
const workspaceMenuItems: WorkspaceMenuItem[] = useMemo(() => {
const protectedMenuItems: WorkspaceMenuItem[] = [];

protectedMenuItems.push({
translationKey: 'common.reports',
icon: Document,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_REPORT_FIELDS.getRoute(policyID)))),
screenName: SCREENS.WORKSPACE.REPORT_FIELDS,
});

if (featureStates?.[CONST.POLICY.MORE_FEATURES.ARE_DISTANCE_RATES_ENABLED]) {
protectedMenuItems.push({
translationKey: 'workspace.common.distanceRates',
Expand Down Expand Up @@ -263,16 +270,6 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
});
}

if (featureStates?.[CONST.POLICY.MORE_FEATURES.ARE_REPORT_FIELDS_ENABLED]) {
protectedMenuItems.push({
translationKey: 'workspace.common.reportFields',
icon: Pencil,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_REPORT_FIELDS.getRoute(policyID)))),
screenName: SCREENS.WORKSPACE.REPORT_FIELDS,
highlighted: highlightedFeature === CONST.POLICY.MORE_FEATURES.ARE_REPORT_FIELDS_ENABLED,
});
}

if (featureStates?.[CONST.POLICY.MORE_FEATURES.ARE_WORKFLOWS_ENABLED]) {
protectedMenuItems.push({
translationKey: 'workspace.common.workflows',
Expand Down
44 changes: 0 additions & 44 deletions src/pages/workspace/WorkspaceMoreFeaturesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
enableExpensifyCard,
enablePolicyConnections,
enablePolicyInvoicing,
enablePolicyReportFields,
enablePolicyRules,
enablePolicyTaxes,
enablePolicyWorkflows,
Expand Down Expand Up @@ -92,7 +91,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
const [cardFeeds] = useCardFeeds(policyID);
const [isOrganizeWarningModalOpen, setIsOrganizeWarningModalOpen] = useState(false);
const [isIntegrateWarningModalOpen, setIsIntegrateWarningModalOpen] = useState(false);
const [isReportFieldsWarningModalOpen, setIsReportFieldsWarningModalOpen] = useState(false);
const [isDisableExpensifyCardWarningModalOpen, setIsDisableExpensifyCardWarningModalOpen] = useState(false);
const [isDisableCompanyCardsWarningModalOpen, setIsDisableCompanyCardsWarningModalOpen] = useState(false);
const [isDisableWorkflowWarningModalOpen, setIsDisableWorkflowWarningModalOpen] = useState(false);
Expand Down Expand Up @@ -284,32 +282,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
enablePolicyTaxes(policyID, isEnabled);
},
},
{
icon: Illustrations.Pencil,
titleTranslationKey: 'workspace.moreFeatures.reportFields.title',
subtitleTranslationKey: 'workspace.moreFeatures.reportFields.subtitle',
isActive: policy?.areReportFieldsEnabled ?? false,
disabled: hasAccountingConnection,
pendingAction: policy?.pendingFields?.areReportFieldsEnabled,
disabledAction: onDisabledOrganizeSwitchPress,
action: (isEnabled: boolean) => {
if (!policyID) {
return;
}
if (isEnabled) {
if (!isControlPolicy(policy)) {
Navigation.navigate(
ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.reportFields.alias, ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID)),
);
return;
}

enablePolicyReportFields(policyID, true, true);
return;
}
setIsReportFieldsWarningModalOpen(true);
},
},
];

const integrateItems: Item[] = [
Expand Down Expand Up @@ -508,22 +480,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
confirmText={translate('workspace.moreFeatures.connectionsWarningModal.manageSettings')}
cancelText={translate('common.cancel')}
/>
<ConfirmModal
title={translate('workspace.reportFields.disableReportFields')}
isVisible={isReportFieldsWarningModalOpen}
onConfirm={() => {
if (!policyID) {
return;
}
setIsReportFieldsWarningModalOpen(false);
enablePolicyReportFields(policyID, false, true);
}}
onCancel={() => setIsReportFieldsWarningModalOpen(false)}
prompt={translate('workspace.reportFields.disableReportFieldsConfirmation')}
confirmText={translate('common.disable')}
cancelText={translate('common.cancel')}
danger
/>
<ConfirmModal
title={translate('workspace.moreFeatures.expensifyCard.disableCardTitle')}
isVisible={isDisableExpensifyCardWarningModalOpen}
Expand Down
Loading