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/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ function isDeletedAction(reportAction: OnyxInputOrEntry<ReportAction | Optimisti
reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED_REPORT_FOR_UNAPPROVED_TRANSACTIONS ||
reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REASSIGN_APPROVER ||
reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_CATEGORIZE_NEW_EXPENSES ||
reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE_DISPLAY_NAME ||
isCardIssuedAction(reportAction) ||
isPolicyCopyReportAction(reportAction)
) {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,9 @@ function ProfilePage({route}: ProfilePageProps) {
</View>
) : null}
{canManageMemberDisplayName ? (
<View style={[styles.w100, styles.detailsPageSectionContainer]}>
<View style={[styles.alignSelfStretch, styles.mhn5]}>
<OfflineWithFeedback pendingAction={details?.pendingFields?.displayName}>
<MenuItemWithTopDescription
style={[styles.ph0]}
title={displayName}
description={translate('displayNamePage.headerTitle')}
interactive={!hasDisplayNameSet}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type SCREENS from '@src/SCREENS';
import INPUT_IDS from '@src/types/form/DisplayNameForm';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';

import React from 'react';
import React, {useState} from 'react';
import {View} from 'react-native';

type WorkspaceMemberDisplayNamePageProps = PlatformStackScreenProps<ProfileNavigatorParamList, typeof SCREENS.DYNAMIC_PROFILE_DISPLAY_NAME>;
Expand All @@ -44,6 +44,9 @@ function WorkspaceMemberDisplayNamePage({route}: WorkspaceMemberDisplayNamePageP
const hasDisplayNameSet = !!memberPersonalDetails?.firstName || !!memberPersonalDetails?.lastName;
const isPolicyMember = !!memberLogin && !!policy?.employeeList?.[memberLogin];

// Saving sets the name straight away, so without this the page would block itself while it closes.
const [hasSubmitted, setHasSubmitted] = useState(false);

const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_MEMBER_DISPLAY_NAME_FORM>) => getDisplayNameErrors(values.firstName, values.lastName, translate);

return (
Expand All @@ -52,7 +55,7 @@ function WorkspaceMemberDisplayNamePage({route}: WorkspaceMemberDisplayNamePageP
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]}
policyFeature={CONST.POLICY.POLICY_FEATURE.MEMBERS}
policyFeatureAccess={CONST.POLICY.POLICY_FEATURE_ACCESS.WRITE}
shouldBeBlocked={!isLoadingMemberPersonalDetails && (hasDisplayNameSet || !isPolicyMember)}
shouldBeBlocked={!isLoadingMemberPersonalDetails && !hasSubmitted && (hasDisplayNameSet || !isPolicyMember)}
>
<ScreenWrapper
includeSafeAreaPaddingBottom
Expand All @@ -75,6 +78,7 @@ function WorkspaceMemberDisplayNamePage({route}: WorkspaceMemberDisplayNamePageP
if (!memberLogin) {
return;
}
setHasSubmitted(true);
updatePolicyMemberDisplayName(policyID, values.firstName.trim(), values.lastName.trim(), formatPhoneNumber, {
accountID,
email: memberLogin,
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/ReportActionsUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,23 @@ describe('ReportActionsUtils', () => {
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(false);
});

it('should return false for POLICY_CHANGE_LOG.UPDATE_EMPLOYEE_DISPLAY_NAME action with an empty message html', () => {
// Given the display name whisper as the backend sends it after a reaction, with an empty message html
const reportAction: ReportAction = {
actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE_DISPLAY_NAME,
reportActionID: '1',
created: '2026-10-13 12:00:03.573',
message: [{html: '', text: '', type: CONST.REPORT.MESSAGE.TYPE.COMMENT, whisperedTo: [590]}],
originalMessage: {oldValue: 'cathy@boulderdev.com', newValue: 'Cathy Miller', whisperedTo: [590]},
};

// When checking whether it is deleted
const isDeleted = ReportActionsUtils.isDeletedAction(reportAction);

// Then it is not, because its text comes from originalMessage
expect(isDeleted).toBe(false);
});

it('should return false for CARDFROZEN action with a backend-provided message fragment', () => {
const reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.CARD_FROZEN> = {
actionName: CONST.REPORT.ACTIONS.TYPE.CARD_FROZEN,
Expand Down
Loading