Skip to content

(Tweaks to the Create Expense Flow) - follow-up - change workspace subtitle #55863

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

2 changes: 1 addition & 1 deletion src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';

Check failure on line 10 in src/components/AvatarWithDisplayName.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import * as ReportUtils from '@libs/ReportUtils';

Check failure on line 11 in src/components/AvatarWithDisplayName.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -69,10 +69,10 @@
const StyleUtils = useStyleUtils();
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`);
const [invoiceReceiverPolicy] = useOnyx(
`${ONYXKEYS.COLLECTION.POLICY}${parentReport?.invoiceReceiver && 'policyID' in parentReport.invoiceReceiver ? parentReport.invoiceReceiver.policyID : -1}`,

Check failure on line 72 in src/components/AvatarWithDisplayName.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

);
const title = ReportUtils.getReportName(report, undefined, undefined, undefined, invoiceReceiverPolicy);
const subtitle = ReportUtils.getChatRoomSubtitle(report);
const subtitle = ReportUtils.getChatRoomSubtitle(report, {isCreateExpenseFlow: true});
const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(report);
const isMoneyRequestOrReport =
ReportUtils.isMoneyRequestReport(report) || ReportUtils.isMoneyRequest(report) || ReportUtils.isTrackExpenseReport(report) || ReportUtils.isInvoiceReport(report);
Expand All @@ -84,8 +84,8 @@

const actorAccountID = useRef<number | null>(null);
useEffect(() => {
const parentReportAction = parentReportActions?.[report?.parentReportActionID ?? '-1'];

Check failure on line 87 in src/components/AvatarWithDisplayName.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

actorAccountID.current = parentReportAction?.actorAccountID ?? -1;

Check failure on line 88 in src/components/AvatarWithDisplayName.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

}, [parentReportActions, report]);

const goToDetailsPage = useCallback(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ import type {
StatementTitleParams,
StepCounterParams,
StripePaidParams,
SubmitsToParams,
SubscriptionCommitmentParams,
SubscriptionSettingsRenewsOnParams,
SubscriptionSettingsSaveUpToParams,
Expand Down Expand Up @@ -1108,6 +1109,7 @@ const translations = {
}),
dates: 'Dates',
rates: 'Rates',
submitsTo: ({name}: SubmitsToParams) => `Submits to ${name}`,
},
notificationPreferencesPage: {
header: 'Notification preferences',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ import type {
StatementTitleParams,
StepCounterParams,
StripePaidParams,
SubmitsToParams,
SubscriptionCommitmentParams,
SubscriptionSettingsRenewsOnParams,
SubscriptionSettingsSaveUpToParams,
Expand Down Expand Up @@ -1106,6 +1107,7 @@ const translations = {
}),
dates: 'Fechas',
rates: 'Tasas',
submitsTo: ({name}: SubmitsToParams) => `Se envía a ${name}`,
},
notificationPreferencesPage: {
header: 'Preferencias de avisos',
Expand Down
5 changes: 5 additions & 0 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ type FlightLayoverParams = {
layover: string;
};

type SubmitsToParams = {
name: string;
};

export type {
AuthenticationErrorParams,
ImportMembersSuccessfullDescriptionParams,
Expand Down Expand Up @@ -819,4 +823,5 @@ export type {
ChatWithAccountManagerParams,
EditDestinationSubtitleParams,
FlightLayoverParams,
SubmitsToParams,
};
15 changes: 13 additions & 2 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import Parser from './Parser';
import Performance from './Performance';
import {getDisplayNameOrDefault} from './PersonalDetailsUtils';
import {addSMSDomainIfPhoneNumber, parsePhoneNumber} from './PhoneNumber';
import {canSendInvoiceFromWorkspace} from './PolicyUtils';
import {canSendInvoiceFromWorkspace, getSubmitToAccountID} from './PolicyUtils';
import {
getCombinedReportActions,
getExportIntegrationLastMessageText,
Expand Down Expand Up @@ -804,7 +804,7 @@ function createOption(
result.tooltipText = getReportParticipantsTitle(visibleParticipantAccountIDs);

hasMultipleParticipants = personalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat || reportUtilsIsGroupChat(report);
subtitle = getChatRoomSubtitle(report);
subtitle = getChatRoomSubtitle(report, {isCreateExpenseFlow: true});

const lastActorDetails = report.lastActorAccountID ? personalDetailMap[report.lastActorAccountID] : null;
const lastActorDisplayName = getLastActorDisplayName(lastActorDetails, hasMultipleParticipants);
Expand Down Expand Up @@ -875,6 +875,17 @@ function getReportOption(participant: Participant): OptionData {
} else {
option.text = getPolicyName(report);
option.alternateText = translateLocal('workspace.common.workspace');

if (report?.policyID) {
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`];
const submitToAccountID = getSubmitToAccountID(policy, report);
const submitsToAccountDetails = allPersonalDetails?.[submitToAccountID];
const subtitle = submitsToAccountDetails?.displayName ?? submitsToAccountDetails?.login;

if (subtitle) {
option.alternateText = translateLocal('iou.submitsTo', {name: subtitle ?? ''});
}
}
}
option.isDisabled = isDraftReport(participant.reportID);
option.selected = participant.selected;
Expand Down
16 changes: 14 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,10 @@ type Thread = {
parentReportActionID: string;
} & Report;

type GetChatRoomSubtitleConfig = {
isCreateExpenseFlow?: boolean;
};

let currentUserEmail: string | undefined;
let currentUserPrivateDomain: string | undefined;
let currentUserAccountID: number | undefined;
Expand Down Expand Up @@ -4372,7 +4376,7 @@ function getPayeeName(report: OnyxEntry<Report>): string | undefined {
/**
* Get either the policyName or domainName the chat is tied to
*/
function getChatRoomSubtitle(report: OnyxEntry<Report>): string | undefined {
function getChatRoomSubtitle(report: OnyxEntry<Report>, config: GetChatRoomSubtitleConfig = {isCreateExpenseFlow: false}): string | undefined {
if (isChatThread(report)) {
return '';
}
Expand All @@ -4393,7 +4397,15 @@ function getChatRoomSubtitle(report: OnyxEntry<Report>): string | undefined {
return report?.reportName?.substring(1) ?? '';
}
if ((isPolicyExpenseChat(report) && !!report?.isOwnPolicyExpenseChat) || isExpenseReport(report)) {
return translateLocal('workspace.common.workspace');
const submitToAccountID = getSubmitToAccountID(getPolicy(report?.policyID), report);
const submitsToAccountDetails = allPersonalDetails?.[submitToAccountID];
const subtitle = submitsToAccountDetails?.displayName ?? submitsToAccountDetails?.login;

if (!subtitle || !config.isCreateExpenseFlow) {
return translateLocal('workspace.common.workspace');
}

return translateLocal('iou.submitsTo', {name: subtitle ?? ''});
}
if (isArchivedReport(getReportNameValuePairs(report?.reportID))) {
return report?.oldPolicyName ?? '';
Expand Down
Loading