From 70e390df66dca8d0ebcfb1530545da95d00cce2f Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 28 Sep 2024 12:08:08 +0800 Subject: [PATCH] only add the invalid mention as title if it's not empty --- src/pages/home/report/ReportFooter.tsx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index 0c989f08437c..bb028b35ad48 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -149,18 +149,20 @@ function ReportFooter({ let assignee: OnyxEntry; let assigneeChatReport; - if (isValidMention) { - assignee = Object.values(allPersonalDetails).find((value) => value?.login === mentionWithDomain) ?? undefined; - if (!Object.keys(assignee ?? {}).length) { - const assigneeAccountID = UserUtils.generateAccountID(mentionWithDomain); - const optimisticDataForNewAssignee = Task.setNewOptimisticAssignee(mentionWithDomain, assigneeAccountID); - assignee = optimisticDataForNewAssignee.assignee; - assigneeChatReport = optimisticDataForNewAssignee.assigneeReport; + if (mentionWithDomain) { + if (isValidMention) { + assignee = Object.values(allPersonalDetails).find((value) => value?.login === mentionWithDomain) ?? undefined; + if (!Object.keys(assignee ?? {}).length) { + const assigneeAccountID = UserUtils.generateAccountID(mentionWithDomain); + const optimisticDataForNewAssignee = Task.setNewOptimisticAssignee(mentionWithDomain, assigneeAccountID); + assignee = optimisticDataForNewAssignee.assignee; + assigneeChatReport = optimisticDataForNewAssignee.assigneeReport; + } + } else { + // If the mention is not valid, include it on the title. + // The mention could be invalid if it's a short mention and failed to be converted to a full mention. + title = `@${mentionWithDomain} ${title}`; } - } else { - // If the mention is not valid, include it on the title. - // The mention could be invalid if it's a short mention and failed to be converted to a full mention. - title = `@${mentionWithDomain} ${title}`; } Task.createTaskAndNavigate(report.reportID, title, '', assignee?.login ?? '', assignee?.accountID, assigneeChatReport, report.policyID); return true;