From 1d4d9086293c1aec9bb7eb8194c4b06ed2b82155 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 22 Feb 2024 00:58:36 +0700 Subject: [PATCH 1/7] fix: 32978 --- src/libs/SidebarUtils.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 49436576295c..9ac5227399f8 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -292,27 +292,35 @@ function getOptionData({ const isThreadMessage = ReportUtils.isThread(report) && reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && reportAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; + // Currently the back-end is not returning the `lastActionName` so I use this to mock, + // ideally it should be returned from the back-end in the `report`, like the `lastMessageText` and `lastMessageHtml` + if (report.lastMessageHtml && report.lastMessageHtml.includes('invited ]*><\/mention-user>/g)?.length ?? []; const verb = - lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM + lastActionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM ? Localize.translate(preferredLocale, 'workspace.invite.invited') : Localize.translate(preferredLocale, 'workspace.invite.removed'); - const users = Localize.translate(preferredLocale, targetAccountIDs.length > 1 ? 'workspace.invite.users' : 'workspace.invite.user'); - result.alternateText = `${lastActorDisplayName} ${verb} ${targetAccountIDs.length} ${users}`.trim(); + const users = Localize.translate(preferredLocale, targetAccountIDsLength > 1 ? 'workspace.invite.users' : 'workspace.invite.user'); + result.alternateText = `${lastActorDisplayName} ${verb} ${targetAccountIDsLength} ${users}`.trim(); const roomName = lastAction?.originalMessage?.roomName ?? ''; if (roomName) { From ae3bb23ddc248bf0626448451a9c017b9fd0bbf0 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 15 Apr 2024 10:36:13 +0700 Subject: [PATCH 2/7] fix: Broken message text in LHN when Inviting someone to room --- src/libs/SidebarUtils.ts | 9 +-------- src/types/onyx/Report.ts | 3 ++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index b487aacad987..fbc8f1361f03 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -323,15 +323,8 @@ function getOptionData({ const isThreadMessage = ReportUtils.isThread(report) && lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && lastAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; - // Currently the back-end is not returning the `lastActionName` so I use this to mock, - // ideally it should be returned from the back-end in the `report`, like the `lastMessageText` and `lastMessageHtml` - if (report.lastMessageHtml && report.lastMessageHtml.includes('invited Date: Mon, 15 Apr 2024 11:32:33 +0700 Subject: [PATCH 3/7] fix: typecheck --- ios/Podfile.lock | 4 ++-- src/libs/SidebarUtils.ts | 7 +++++-- src/types/onyx/Report.ts | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 231ce0248d5e..fb15b1af32ad 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -2582,8 +2582,8 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 3033e0dd5272d46e97bcb406adea4ae0e6907abf - Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 + Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 PODFILE CHECKSUM: a25a81f2b50270f0c0bd0aff2e2ebe4d0b4ec06d -COCOAPODS: 1.13.0 +COCOAPODS: 1.14.3 diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index fbc8f1361f03..de8c86d38c8c 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -12,6 +12,7 @@ import type Report from '@src/types/onyx/Report'; import type {ReportActions} from '@src/types/onyx/ReportAction'; import type ReportAction from '@src/types/onyx/ReportAction'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; +import type { ChangeLog } from '@src/types/onyx/OriginalMessage'; import * as CollectionUtils from './CollectionUtils'; import {hasValidDraftComment} from './DraftCommentUtils'; import localeCompare from './LocaleCompare'; @@ -337,7 +338,9 @@ function getOptionData({ lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM || lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.REMOVE_FROM_ROOM ) { - const targetAccountIDsLength = lastAction?.originalMessage?.targetAccountIDs?.length ?? report.lastMessageHtml?.match(/]*><\/mention-user>/g)?.length ?? []; + const lastActionOriginalMessage = lastAction.actionName ? lastAction?.originalMessage as ChangeLog : null ; + const targetAccountIDs = lastActionOriginalMessage?.targetAccountIDs ?? [] + const targetAccountIDsLength = targetAccountIDs.length ?? report.lastMessageHtml?.match(/]*><\/mention-user>/g)?.length ?? 0; const verb = lastActionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM ? Localize.translate(preferredLocale, 'workspace.invite.invited') @@ -345,7 +348,7 @@ function getOptionData({ const users = Localize.translate(preferredLocale, targetAccountIDsLength > 1 ? 'workspace.invite.users' : 'workspace.invite.user'); result.alternateText = `${lastActorDisplayName} ${verb} ${targetAccountIDsLength} ${users}`.trim(); - const roomName = lastAction?.originalMessage?.roomName ?? ''; + const roomName = lastActionOriginalMessage?.roomName ?? ''; if (roomName) { const preposition = lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 280faf23de5e..f53eecb82fa0 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -138,7 +138,7 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< lastMessageHtml?: string; lastActorAccountID?: number; // indicate the type of the last action - lastActionType?: typeof CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG; + lastActionType?: ValueOf; ownerAccountID?: number; ownerEmail?: string; participants?: Participants; From 09b32d5d412a983001346ca16c3eaa7e89252af4 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 25 Apr 2024 16:08:30 +0700 Subject: [PATCH 4/7] fix lint --- ios/Podfile.lock | 4 ++-- src/libs/SidebarUtils.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index acca6566753c..6ef495a65bd3 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -2586,8 +2586,8 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 3033e0dd5272d46e97bcb406adea4ae0e6907abf - Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 + Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 PODFILE CHECKSUM: a25a81f2b50270f0c0bd0aff2e2ebe4d0b4ec06d -COCOAPODS: 1.14.3 +COCOAPODS: 1.13.0 diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index eb09cd4f7137..f09c2868dfa9 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -6,12 +6,12 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PersonalDetails, PersonalDetailsList, TransactionViolation} from '@src/types/onyx'; import type Beta from '@src/types/onyx/Beta'; +import type {ChangeLog} from '@src/types/onyx/OriginalMessage'; import type Policy from '@src/types/onyx/Policy'; import type Report from '@src/types/onyx/Report'; import type {ReportActions} from '@src/types/onyx/ReportAction'; import type ReportAction from '@src/types/onyx/ReportAction'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; -import type { ChangeLog } from '@src/types/onyx/OriginalMessage'; import * as CollectionUtils from './CollectionUtils'; import {hasValidDraftComment} from './DraftCommentUtils'; import localeCompare from './LocaleCompare'; @@ -337,8 +337,8 @@ function getOptionData({ lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM || lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.REMOVE_FROM_ROOM ) { - const lastActionOriginalMessage = lastAction.actionName ? lastAction?.originalMessage as ChangeLog : null ; - const targetAccountIDs = lastActionOriginalMessage?.targetAccountIDs ?? [] + const lastActionOriginalMessage = lastAction.actionName ? (lastAction?.originalMessage as ChangeLog) : null; + const targetAccountIDs = lastActionOriginalMessage?.targetAccountIDs ?? []; const targetAccountIDsLength = targetAccountIDs.length ?? report.lastMessageHtml?.match(/]*><\/mention-user>/g)?.length ?? 0; const verb = lastActionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM From 083b48358d377a75851eb8a6371452fbdb3a0ddc Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 25 Apr 2024 16:19:53 +0700 Subject: [PATCH 5/7] fix lint --- src/libs/SidebarUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index f09c2868dfa9..34c4c98fcc3d 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -337,9 +337,9 @@ function getOptionData({ lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM || lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.REMOVE_FROM_ROOM ) { - const lastActionOriginalMessage = lastAction.actionName ? (lastAction?.originalMessage as ChangeLog) : null; + const lastActionOriginalMessage = lastAction?.actionName ? (lastAction?.originalMessage as ChangeLog) : null; const targetAccountIDs = lastActionOriginalMessage?.targetAccountIDs ?? []; - const targetAccountIDsLength = targetAccountIDs.length ?? report.lastMessageHtml?.match(/]*><\/mention-user>/g)?.length ?? 0; + const targetAccountIDsLength = targetAccountIDs.length !== 0 ? targetAccountIDs.length : report.lastMessageHtml?.match(/]*><\/mention-user>/g)?.length ?? 0; const verb = lastActionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM ? Localize.translate(preferredLocale, 'workspace.invite.invited') From cad58172a84d6e490cf7f22c79c6d72f467b827e Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Sat, 27 Apr 2024 16:50:49 +0700 Subject: [PATCH 6/7] add empty line --- src/types/onyx/Report.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 79e4b40fbb7e..30984e99eb94 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -138,6 +138,7 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< displayName?: string; lastMessageHtml?: string; lastActorAccountID?: number; + // indicate the type of the last action lastActionType?: ValueOf; ownerAccountID?: number; @@ -152,6 +153,7 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< managerEmail?: string; parentReportActionIDs?: number[]; errorFields?: OnyxCommon.ErrorFields; + /** Whether the report is waiting on a bank account */ isWaitingOnBankAccount?: boolean; From 642d7e095c542592b851e82433a9fc0f4d9f1dfb Mon Sep 17 00:00:00 2001 From: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> Date: Sat, 27 Apr 2024 17:07:21 +0700 Subject: [PATCH 7/7] Update src/types/onyx/Report.ts Co-authored-by: DylanDylann <141406735+DylanDylann@users.noreply.github.com> --- src/types/onyx/Report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 30984e99eb94..1848afca25da 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -139,7 +139,7 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< lastMessageHtml?: string; lastActorAccountID?: number; - // indicate the type of the last action + // The type of the last action lastActionType?: ValueOf; ownerAccountID?: number; ownerEmail?: string;