From 3805d4aa2f9b3414c3f0a756ef70d642035c6c05 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 23 Dec 2024 10:58:24 +0700 Subject: [PATCH 1/4] fix: strange next steps message format --- src/libs/NextStepUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 64db07491100..1133ac6052c3 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -47,7 +47,7 @@ function parseMessage(messages: Message[] | undefined) { if (currentUserEmail === part.text || part.clickToCopyText === currentUserEmail) { tagType = 'strong'; - content = nextPart?.text === `'s` ? 'Your' : 'You'; + content = nextPart?.text === `'s` ? 'your' : 'you'; } else if (part.text === `'s` && (previousPart?.text === currentUserEmail || previousPart?.clickToCopyText === currentUserEmail)) { content = ''; } else if (isEmail) { @@ -143,7 +143,7 @@ function buildNextStep(report: OnyxEntry, predictedNextStatus: ValueOf Date: Mon, 23 Dec 2024 14:44:55 +0700 Subject: [PATCH 2/4] fix lint and test --- src/libs/NextStepUtils.ts | 2 +- tests/unit/NextStepUtilsTest.ts | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 1133ac6052c3..536bb8d2dc37 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -23,7 +23,7 @@ Onyx.connect({ return; } - currentUserAccountID = value?.accountID ?? -1; + currentUserAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID; currentUserEmail = value?.email ?? ''; }, }); diff --git a/tests/unit/NextStepUtilsTest.ts b/tests/unit/NextStepUtilsTest.ts index 776c5f95cce7..e340a82fdbee 100644 --- a/tests/unit/NextStepUtilsTest.ts +++ b/tests/unit/NextStepUtilsTest.ts @@ -122,7 +122,6 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, - type: 'strong', }, { text: "'s", @@ -157,7 +156,6 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, - type: 'strong', }, { text: "'s", @@ -192,7 +190,6 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, - type: 'strong', }, { text: "'s", @@ -227,7 +224,6 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, - type: 'strong', }, { text: "'s", @@ -263,7 +259,6 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, - type: 'strong', }, { text: "'s", @@ -301,7 +296,6 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, - type: 'strong', }, { text: "'s", @@ -337,7 +331,6 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, - type: 'strong', }, { text: "'s", @@ -371,7 +364,6 @@ describe('libs/NextStepUtils', () => { }, { text: `${currentUserEmail}`, - type: 'strong', }, { text: ' to ', From 5fdac292193388c2f98b908ab8a59d7d1c497311 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 14 Jan 2025 15:01:24 +0700 Subject: [PATCH 3/4] Not bold you and your --- src/libs/NextStepUtils.ts | 2 +- tests/unit/NextStepUtilsTest.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 536bb8d2dc37..6e5f02b14b1d 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -143,7 +143,7 @@ function buildNextStep(report: OnyxEntry, predictedNextStatus: ValueOf { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, + type: 'strong', }, { text: "'s", @@ -156,6 +157,7 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, + type: 'strong', }, { text: "'s", @@ -190,6 +192,7 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, + type: 'strong', }, { text: "'s", @@ -224,6 +227,7 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, + type: 'strong', }, { text: "'s", @@ -259,6 +263,7 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, + type: 'strong', }, { text: "'s", @@ -296,6 +301,7 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, + type: 'strong', }, { text: "'s", @@ -331,6 +337,7 @@ describe('libs/NextStepUtils', () => { { text: `${currentUserEmail}`, clickToCopyText: `${currentUserEmail}`, + type: 'strong', }, { text: "'s", @@ -364,6 +371,7 @@ describe('libs/NextStepUtils', () => { }, { text: `${currentUserEmail}`, + type: 'strong', }, { text: ' to ', From 0f70d191fb2e58d643a70be556b60863cd9663de Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 14 Jan 2025 15:07:36 +0700 Subject: [PATCH 4/4] fix lint --- src/libs/NextStepUtils.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 6e5f02b14b1d..85a91927502a 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -11,8 +11,8 @@ import type DeepValueOf from '@src/types/utils/DeepValueOf'; import {getNextApproverAccountID} from './actions/IOU'; import DateUtils from './DateUtils'; import EmailUtils from './EmailUtils'; -import * as PolicyUtils from './PolicyUtils'; -import * as ReportUtils from './ReportUtils'; +import {getCorrectedAutoReportingFrequency, getReimburserAccountID} from './PolicyUtils'; +import {getDisplayNameForParticipant, getPersonalDetailsForAccountID, isExpenseReport, isInvoiceReport, isPayer} from './ReportUtils'; let currentUserAccountID = -1; let currentUserEmail = ''; @@ -69,7 +69,7 @@ function parseMessage(messages: Message[] | undefined) { function getNextApproverDisplayName(report: OnyxEntry) { const approverAccountID = getNextApproverAccountID(report); - return ReportUtils.getDisplayNameForParticipant(approverAccountID) ?? ReportUtils.getPersonalDetailsForAccountID(approverAccountID).login; + return getDisplayNameForParticipant(approverAccountID) ?? getPersonalDetailsForAccountID(approverAccountID).login; } /** @@ -81,18 +81,18 @@ function getNextApproverDisplayName(report: OnyxEntry) { * @returns nextStep */ function buildNextStep(report: OnyxEntry, predictedNextStatus: ValueOf): ReportNextStep | null { - if (!ReportUtils.isExpenseReport(report)) { + if (!isExpenseReport(report)) { return null; } const {policyID = '', ownerAccountID = -1} = report ?? {}; const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`] ?? ({} as Policy); const {harvesting, autoReportingOffset} = policy; - const autoReportingFrequency = PolicyUtils.getCorrectedAutoReportingFrequency(policy); - const ownerDisplayName = ReportUtils.getDisplayNameForParticipant(ownerAccountID); + const autoReportingFrequency = getCorrectedAutoReportingFrequency(policy); + const ownerDisplayName = getDisplayNameForParticipant(ownerAccountID); const nextApproverDisplayName = getNextApproverDisplayName(report); - const reimburserAccountID = PolicyUtils.getReimburserAccountID(policy); + const reimburserAccountID = getReimburserAccountID(policy); const hasValidAccount = !!policy?.achAccount?.accountNumber; const type: ReportNextStep['type'] = 'neutral'; let optimisticNextStep: ReportNextStep | null; @@ -240,8 +240,8 @@ function buildNextStep(report: OnyxEntry, predictedNextStatus: ValueOf, predictedNextStatus: ValueOf