From 9bfa9c232e81acdaef9e7cef6daaf0760ec8c365 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 21 Oct 2024 23:14:18 +0900 Subject: [PATCH 1/6] fix owner tooltip --- src/pages/home/report/ReportActionItemSingle.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 5e1f0a591532..892cfe3042b0 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -220,7 +220,7 @@ function ReportActionItemSingle({ } return ( @@ -271,7 +271,7 @@ function ReportActionItemSingle({ Date: Mon, 21 Oct 2024 23:17:26 +0900 Subject: [PATCH 2/6] match pattern --- src/pages/home/report/ReportActionItemSingle.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 892cfe3042b0..445f4c37ce2c 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -271,7 +271,7 @@ function ReportActionItemSingle({ Date: Tue, 22 Oct 2024 13:01:49 +0900 Subject: [PATCH 3/6] set actor to owner for expense reports --- src/pages/home/report/ReportActionItemSingle.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 445f4c37ce2c..7eaa4ce37430 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -85,7 +85,9 @@ function ReportActionItemSingle({ const personalDetails = usePersonalDetails() ?? CONST.EMPTY_OBJECT; const policy = usePolicy(report?.policyID); const delegatePersonalDetails = personalDetails[action?.delegateAccountID ?? '']; - const actorAccountID = ReportUtils.getReportActionActorAccountID(action, iouReport); + const ownerAccountID = iouReport?.ownerAccountID ?? action?.childOwnerAccountID; + const isReportPreviewAction = action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW; + const actorAccountID = isReportPreviewAction && ReportUtils.isPolicyExpenseChat(report) ? ownerAccountID : ReportUtils.getReportActionActorAccountID(action, iouReport); const [invoiceReceiverPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : -1}`); let displayName = ReportUtils.getDisplayNameForParticipant(actorAccountID); @@ -94,20 +96,13 @@ function ReportActionItemSingle({ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing let actorHint = (login || (displayName ?? '')).replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); const isTripRoom = ReportUtils.isTripRoom(report); - const isReportPreviewAction = action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW; const displayAllActors = isReportPreviewAction && !isTripRoom && !ReportUtils.isPolicyExpenseChat(report); const isInvoiceReport = ReportUtils.isInvoiceReport(iouReport ?? null); const isWorkspaceActor = isInvoiceReport || (ReportUtils.isPolicyExpenseChat(report) && (!actorAccountID || displayAllActors)); - const ownerAccountID = iouReport?.ownerAccountID ?? action?.childOwnerAccountID; + let avatarSource = avatar; let avatarId: number | string | undefined = actorAccountID; - if (isReportPreviewAction && ReportUtils.isPolicyExpenseChat(report)) { - avatarId = ownerAccountID; - avatarSource = personalDetails[ownerAccountID ?? -1]?.avatar; - displayName = ReportUtils.getDisplayNameForParticipant(ownerAccountID); - actorHint = displayName; - } if (isWorkspaceActor) { displayName = ReportUtils.getPolicyName(report, undefined, policy); actorHint = displayName; From 5689ea90bda7eee62a06140af7213a02be5ae073 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Tue, 22 Oct 2024 16:45:56 +0900 Subject: [PATCH 4/6] move to utils --- src/libs/ReportUtils.ts | 9 ++++++--- src/pages/home/report/ReportActionItemSingle.tsx | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 4bae619d928e..6749098fc232 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -8012,10 +8012,13 @@ function canLeaveChat(report: OnyxEntry, policy: OnyxEntry): boo return (isChatThread(report) && !!getReportNotificationPreference(report)) || isUserCreatedPolicyRoom(report) || isNonAdminOrOwnerOfPolicyExpenseChat(report, policy); } -function getReportActionActorAccountID(reportAction: OnyxInputOrEntry, iouReport: OnyxInputOrEntry | undefined): number | undefined { +function getReportActionActorAccountID(reportAction: OnyxInputOrEntry, iouReport: OnyxInputOrEntry | undefined, isPolicyExpenseChat: boolean): number | undefined { switch (reportAction?.actionName) { - case CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW: - return !isEmptyObject(iouReport) ? iouReport.managerID : reportAction?.childManagerAccountID; + case CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW: { + const ownerAccountID = iouReport?.ownerAccountID ?? reportAction?.childOwnerAccountID; + const actorAccountID = iouReport?.managerID ?? reportAction?.childManagerAccountID; + return isPolicyExpenseChat ? ownerAccountID : actorAccountID; + } case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: return reportAction?.adminAccountID ?? reportAction?.actorAccountID; diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 7eaa4ce37430..462fc16540b9 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -87,7 +87,7 @@ function ReportActionItemSingle({ const delegatePersonalDetails = personalDetails[action?.delegateAccountID ?? '']; const ownerAccountID = iouReport?.ownerAccountID ?? action?.childOwnerAccountID; const isReportPreviewAction = action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW; - const actorAccountID = isReportPreviewAction && ReportUtils.isPolicyExpenseChat(report) ? ownerAccountID : ReportUtils.getReportActionActorAccountID(action, iouReport); + const actorAccountID = ReportUtils.getReportActionActorAccountID(action, iouReport, ReportUtils.isPolicyExpenseChat(report)); const [invoiceReceiverPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : -1}`); let displayName = ReportUtils.getDisplayNameForParticipant(actorAccountID); From b029e64b5a36cdf439634f36b92abf19fa53aa5c Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Tue, 29 Oct 2024 13:30:34 +0000 Subject: [PATCH 5/6] type error --- src/libs/ReportUtils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index bbb1d9ec220c..8be83c7c3ccc 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -8034,12 +8034,16 @@ function canLeaveChat(report: OnyxEntry, policy: OnyxEntry): boo return (isChatThread(report) && !!getReportNotificationPreference(report)) || isUserCreatedPolicyRoom(report) || isNonAdminOrOwnerOfPolicyExpenseChat(report, policy); } -function getReportActionActorAccountID(reportAction: OnyxInputOrEntry, iouReport: OnyxInputOrEntry | undefined, isPolicyExpenseChat: boolean): number | undefined { +function getReportActionActorAccountID( + reportAction: OnyxInputOrEntry, + iouReport: OnyxInputOrEntry | undefined, + isPolicyExpenseChatParam: boolean | undefined, +): number | undefined { switch (reportAction?.actionName) { case CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW: { const ownerAccountID = iouReport?.ownerAccountID ?? reportAction?.childOwnerAccountID; const actorAccountID = iouReport?.managerID ?? reportAction?.childManagerAccountID; - return isPolicyExpenseChat ? ownerAccountID : actorAccountID; + return isPolicyExpenseChatParam ? ownerAccountID : actorAccountID; } case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: From 69ad164d2388f963b139b8fd14d436e28f4d7210 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Tue, 29 Oct 2024 13:35:52 +0000 Subject: [PATCH 6/6] clean up --- src/libs/ReportUtils.ts | 7 +++---- src/pages/home/report/ReportActionItemSingle.tsx | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8be83c7c3ccc..09176ceefc8f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2298,7 +2298,7 @@ function getIcons( if (isChatThread(report)) { const parentReportAction = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.[report.parentReportActionID]; - const actorAccountID = getReportActionActorAccountID(parentReportAction, report); + const actorAccountID = getReportActionActorAccountID(parentReportAction, report, report); const actorDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(allPersonalDetails?.[actorAccountID ?? -1], '', false); const actorIcon = { id: actorAccountID, @@ -8037,13 +8037,13 @@ function canLeaveChat(report: OnyxEntry, policy: OnyxEntry): boo function getReportActionActorAccountID( reportAction: OnyxInputOrEntry, iouReport: OnyxInputOrEntry | undefined, - isPolicyExpenseChatParam: boolean | undefined, + report: OnyxInputOrEntry | undefined, ): number | undefined { switch (reportAction?.actionName) { case CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW: { const ownerAccountID = iouReport?.ownerAccountID ?? reportAction?.childOwnerAccountID; const actorAccountID = iouReport?.managerID ?? reportAction?.childManagerAccountID; - return isPolicyExpenseChatParam ? ownerAccountID : actorAccountID; + return isPolicyExpenseChat(report) ? ownerAccountID : actorAccountID; } case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: @@ -8053,7 +8053,6 @@ function getReportActionActorAccountID( return reportAction?.actorAccountID; } } - function createDraftWorkspaceAndNavigateToConfirmationScreen(transactionID: string, actionName: IOUAction): void { const isCategorizing = actionName === CONST.IOU.ACTION.CATEGORIZE; const {expenseChatReportID, policyID, policyName} = PolicyActions.createDraftWorkspace(); diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 462fc16540b9..0fed9d8a6c49 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -87,7 +87,7 @@ function ReportActionItemSingle({ const delegatePersonalDetails = personalDetails[action?.delegateAccountID ?? '']; const ownerAccountID = iouReport?.ownerAccountID ?? action?.childOwnerAccountID; const isReportPreviewAction = action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW; - const actorAccountID = ReportUtils.getReportActionActorAccountID(action, iouReport, ReportUtils.isPolicyExpenseChat(report)); + const actorAccountID = ReportUtils.getReportActionActorAccountID(action, iouReport, report); const [invoiceReceiverPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : -1}`); let displayName = ReportUtils.getDisplayNameForParticipant(actorAccountID);