From d7ba371dd1db5ae8943fae845d862a950603d98a Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Fri, 12 Jul 2024 17:16:31 +0700 Subject: [PATCH 1/8] using report name value to check archived --- .../BaseAnchorForAttachmentsOnly.tsx | 11 ++- .../HTMLRenderers/ImageRenderer.tsx | 11 ++- .../HTMLRenderers/MentionUserRenderer.tsx | 11 ++- .../HTMLRenderers/PreRenderer.tsx | 11 ++- src/components/ShowContextMenuContext.ts | 2 +- .../VideoPlayerThumbnail.tsx | 11 ++- src/libs/OptionsListUtils.ts | 6 +- src/libs/ReportUtils.ts | 71 ++++++++++++------- src/libs/SidebarUtils.ts | 6 +- src/libs/actions/IOU.ts | 6 +- src/libs/actions/Task.ts | 3 +- src/pages/ReportDetailsPage.tsx | 7 +- src/pages/ReportParticipantsPage.tsx | 5 +- src/pages/home/report/ReportActionItem.tsx | 4 +- src/pages/home/report/ReportActionsList.tsx | 8 ++- .../withReportAndPrivateNotesOrNotFound.tsx | 7 +- .../FloatingActionButtonAndPopover.tsx | 5 +- .../iou/request/step/IOURequestStepAmount.tsx | 9 +-- .../request/step/IOURequestStepDistance.tsx | 12 ++-- .../step/IOURequestStepScan/index.native.tsx | 9 ++- .../request/step/IOURequestStepScan/index.tsx | 10 +-- .../Report/NotificationPreferencePage.tsx | 5 +- .../settings/Report/ReportSettingsPage.tsx | 5 +- src/pages/settings/Report/VisibilityPage.tsx | 5 +- src/types/onyx/ReportNameValuePairs.ts | 6 +- 25 files changed, 179 insertions(+), 67 deletions(-) diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index 48604ec364c71..7a0d6d522e335 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -53,7 +53,16 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', dow }} onPressIn={onPressIn} onPressOut={onPressOut} - onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} + onLongPress={(event) => + showContextMenuForReport( + event, + anchor, + report?.reportID ?? '-1', + action, + checkIfContextMenuActive, + ReportUtils.isArchivedRoom(report, ReportUtils.getReportNameValuePair(report?.reportID)), + ) + } shouldUseHapticsOnLongPress accessibilityLabel={displayName} role={CONST.ROLE.BUTTON} diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx index 67bbc7986bc7a..76046a4a895d2 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx @@ -93,7 +93,16 @@ function ImageRenderer({tnode}: ImageRendererProps) { Navigation.navigate(route); } }} - onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} + onLongPress={(event) => + showContextMenuForReport( + event, + anchor, + report?.reportID ?? '-1', + action, + checkIfContextMenuActive, + ReportUtils.isArchivedRoom(report, ReportUtils.getReportNameValuePair(report?.reportID)), + ) + } shouldUseHapticsOnLongPress accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON} accessibilityLabel={translate('accessibilityHints.viewAttachment')} diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index e5481c5d90944..9266b7f229e54 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -86,7 +86,16 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona {({anchor, report, action, checkIfContextMenuActive}) => ( showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} + onLongPress={(event) => + showContextMenuForReport( + event, + anchor, + report?.reportID ?? '-1', + action, + checkIfContextMenuActive, + ReportUtils.isArchivedRoom(report, ReportUtils.getReportNameValuePair(report?.reportID)), + ) + } onPress={(event) => { event.preventDefault(); Navigation.navigate(navigationRoute); diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx index 4d1e58a428300..396c64ab53569 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx @@ -39,7 +39,16 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d onPress={onPressIn ?? (() => {})} onPressIn={onPressIn} onPressOut={onPressOut} - onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} + onLongPress={(event) => + showContextMenuForReport( + event, + anchor, + report?.reportID ?? '-1', + action, + checkIfContextMenuActive, + ReportUtils.isArchivedRoom(report, ReportUtils.getReportNameValuePair(report?.reportID)), + ) + } shouldUseHapticsOnLongPress role={CONST.ROLE.PRESENTATION} accessibilityLabel={translate('accessibilityHints.prestyledText')} diff --git a/src/components/ShowContextMenuContext.ts b/src/components/ShowContextMenuContext.ts index 5e4cb8dfcc90e..5df8bc123bba3 100644 --- a/src/components/ShowContextMenuContext.ts +++ b/src/components/ShowContextMenuContext.ts @@ -17,7 +17,7 @@ type ShowContextMenuContextProps = { checkIfContextMenuActive: () => void; }; -const ShowContextMenuContext = createContext({ +const ShowContextMenuContext = createContext({ anchor: null, report: undefined, action: undefined, diff --git a/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx b/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx index 719438b87931a..55812776a6c64 100644 --- a/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx +++ b/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx @@ -48,7 +48,16 @@ function VideoPlayerThumbnail({thumbnailUrl, onPress, accessibilityLabel}: Video onPress={onPress} onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} - onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} + onLongPress={(event) => + showContextMenuForReport( + event, + anchor, + report?.reportID ?? '-1', + action, + checkIfContextMenuActive, + ReportUtils.isArchivedRoom(report, ReportUtils.getReportNameValuePair(report?.reportID)), + ) + } shouldUseHapticsOnLongPress > diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 97c9a0965f1d8..016d2ab03d232 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -663,8 +663,9 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails // some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action const lastOriginalReportAction = lastReportActions[reportID] ?? null; let lastMessageTextFromReport = ''; + const reportNameValuePairs = ReportUtils.getReportNameValuePair(report?.reportID); - if (ReportUtils.isArchivedRoom(report)) { + if (ReportUtils.isArchivedRoom(report, reportNameValuePairs)) { const archiveReason = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing (ReportActionUtils.isClosedAction(lastOriginalReportAction) && ReportActionUtils.getOriginalMessage(lastOriginalReportAction)?.reason) || CONST.REPORT.ARCHIVE_REASON.DEFAULT; @@ -786,10 +787,11 @@ function createOption( let reportName; result.participantsList = personalDetailList; result.isOptimisticPersonalDetail = personalDetail?.isOptimisticPersonalDetail; + const reportNameValuePairs = ReportUtils.getReportNameValuePair(report?.reportID); if (report) { result.isChatRoom = ReportUtils.isChatRoom(report); result.isDefaultRoom = ReportUtils.isDefaultRoom(report); - result.isArchivedRoom = ReportUtils.isArchivedRoom(report); + result.isArchivedRoom = ReportUtils.isArchivedRoom(report, reportNameValuePairs); result.isExpenseReport = ReportUtils.isExpenseReport(report); result.isInvoiceRoom = ReportUtils.isInvoiceRoom(report); result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 9fe81b7de5b17..ab4af7adba662 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -566,6 +566,18 @@ Onyx.connect({ }, }); +let allReportNameValuePair: OnyxCollection; +Onyx.connect({ + key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, + waitForCollectionCallback: true, + callback: (value) => { + if (!value) { + return; + } + allReportNameValuePair = value; + }, +}); + let isFirstTimeNewExpensifyUser = false; Onyx.connect({ key: ONYXKEYS.NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER, @@ -623,6 +635,14 @@ function getReport(reportID: string): OnyxEntry { return ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; } +/** + * Returns the report + */ +function getReportNameValuePair(reportID?: string): OnyxEntry { + // ?? ([] as ReportNameValuePairs[]) + return allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID ?? -1}`]; +} + /** * Returns the parentReport if the given report is a thread */ @@ -1270,7 +1290,7 @@ function isClosedExpenseReportWithNoExpenses(report: OnyxEntry): boolean */ function isArchivedRoom(report: OnyxInputOrEntry, reportNameValuePairs?: OnyxInputOrEntry): boolean { if (reportNameValuePairs) { - return reportNameValuePairs.isArchived; + return !!(reportNameValuePairs?.isArchived ?? reportNameValuePairs?.private_isArchived); } return report?.statusNum === CONST.REPORT.STATUS_NUM.CLOSED && report?.stateNum === CONST.REPORT.STATE_NUM.APPROVED; @@ -1282,7 +1302,7 @@ function isArchivedRoom(report: OnyxInputOrEntry, reportNameValuePairs?: function isArchivedRoomWithID(reportID?: string) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const report = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID || -1}`]; - return isArchivedRoom(report); + return isArchivedRoom(report, getReportNameValuePair(reportID)); } /** @@ -1639,7 +1659,7 @@ function getRoomWelcomeMessage(report: OnyxEntry): WelcomeMessage { const welcomeMessage: WelcomeMessage = {showReportName: true}; const workspaceName = getPolicyName(report); - if (isArchivedRoom(report)) { + if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfArchivedRoomPartOne'); welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfArchivedRoomPartTwo'); } else if (isDomainRoom(report)) { @@ -2059,7 +2079,7 @@ function getIcons( }; return [domainIcon]; } - if (isAdminRoom(report) || isAnnounceRoom(report) || isChatRoom(report) || isArchivedRoom(report)) { + if (isAdminRoom(report) || isAnnounceRoom(report) || isChatRoom(report) || isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { const icons = [getWorkspaceIcon(report, policy)]; if (isInvoiceRoom(report)) { @@ -2374,7 +2394,10 @@ function requiresAttentionFromCurrentUser(optionOrReport: OnyxEntry | Op return true; } - if (isArchivedRoom(optionOrReport) || isArchivedRoom(getReportOrDraftReport(optionOrReport.parentReportID))) { + if ( + isArchivedRoom(optionOrReport, getReportNameValuePair(optionOrReport?.reportID)) || + isArchivedRoom(getReportOrDraftReport(optionOrReport.parentReportID), getReportNameValuePair(optionOrReport?.reportID)) + ) { return false; } @@ -2453,7 +2476,6 @@ function getPolicyExpenseChatName(report: OnyxEntry, policy?: OnyxEntry< const login = personalDetails ? personalDetails.login : null; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const reportOwnerDisplayName = getDisplayNameForParticipant(ownerAccountID) || login || report?.reportName; - // If the policy expense chat is owned by this user, use the name of the policy as the report name. if (report?.isOwnPolicyExpenseChat) { return getPolicyName(report, false, policy); @@ -2467,7 +2489,7 @@ function getPolicyExpenseChatName(report: OnyxEntry, policy?: OnyxEntry< // If this user is not admin and this policy expense chat has been archived because of account merging, this must be an old workspace chat // of the account which was merged into the current user's account. Use the name of the policy as the name of the report. - if (isArchivedRoom(report)) { + if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { const lastAction = ReportActionsUtils.getLastVisibleAction(report?.reportID ?? '-1'); const archiveReason = ReportActionsUtils.isClosedAction(lastAction) ? ReportActionsUtils.getOriginalMessage(lastAction)?.reason : CONST.REPORT.ARCHIVE_REASON.DEFAULT; if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED && policyExpenseChatRole !== CONST.POLICY.ROLE.ADMIN) { @@ -3389,7 +3411,7 @@ function getReportName(report: OnyxEntry, policy?: OnyxEntry, pa if (isChatThread(report)) { if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction)) { formattedName = getTransactionReportName(parentReportAction); - if (isArchivedRoom(report)) { + if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { formattedName += ` (${Localize.translateLocal('common.archived')})`; } return formatReportLastMessageText(formattedName); @@ -3414,7 +3436,7 @@ function getReportName(report: OnyxEntry, policy?: OnyxEntry, pa if (isAdminRoom(report) || isUserCreatedPolicyRoom(report)) { return getAdminRoomInvitedParticipants(parentReportAction, parentReportActionMessage); } - if (parentReportActionMessage && isArchivedRoom(report)) { + if (parentReportActionMessage && isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { return `${parentReportActionMessage} (${Localize.translateLocal('common.archived')})`; } if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isModifiedExpenseAction(parentReportAction)) { @@ -3456,7 +3478,7 @@ function getReportName(report: OnyxEntry, policy?: OnyxEntry, pa formattedName = getInvoicesChatName(report); } - if (isArchivedRoom(report)) { + if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { formattedName += ` (${Localize.translateLocal('common.archived')})`; } @@ -3525,7 +3547,7 @@ function getChatRoomSubtitle(report: OnyxEntry): string | undefined { if ((isPolicyExpenseChat(report) && !!report?.isOwnPolicyExpenseChat) || isExpenseReport(report)) { return Localize.translateLocal('workspace.common.workspace'); } - if (isArchivedRoom(report)) { + if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { return report?.oldPolicyName ?? ''; } return getPolicyName(report); @@ -3551,7 +3573,7 @@ function getParentNavigationSubtitle(report: OnyxEntry): ParentNavigatio if (isInvoiceReport(report) || isInvoiceRoom(parentReport)) { let reportName = `${getPolicyName(parentReport)} & ${getInvoicePayerName(parentReport)}`; - if (isArchivedRoom(parentReport)) { + if (isArchivedRoom(parentReport, getReportNameValuePair(parentReport?.reportID))) { reportName += ` (${Localize.translateLocal('common.archived')})`; } @@ -5302,7 +5324,7 @@ function isIOUOwnedByCurrentUser(report: OnyxEntry, allReportsDict?: Ony */ function canSeeDefaultRoom(report: OnyxEntry, policies: OnyxCollection, betas: OnyxEntry): boolean { // Include archived rooms - if (isArchivedRoom(report)) { + if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { return true; } @@ -5456,7 +5478,7 @@ function shouldReportBeInOptionList({ // So we allow showing rooms with no participants–in any other circumstances we should never have these reports with no participants in Onyx. !isChatRoom(report) && !isChatThread(report) && - !isArchivedRoom(report) && + !isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && !isMoneyRequestReport(report) && !isTaskReport(report) && !isSelfDM(report) && @@ -5531,7 +5553,7 @@ function shouldReportBeInOptionList({ } // Archived reports should always be shown when in default (most recent) mode. This is because you should still be able to access and search for the chats to find them. - if (isInDefaultMode && isArchivedRoom(report)) { + if (isInDefaultMode && isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { return true; } @@ -5693,7 +5715,7 @@ function canFlagReportAction(reportAction: OnyxInputOrEntry, repor function shouldShowFlagComment(reportAction: OnyxInputOrEntry, report: OnyxInputOrEntry): boolean { return ( canFlagReportAction(reportAction, report?.reportID) && - !isArchivedRoom(report) && + !isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && !chatIncludesChronos(report) && !isConciergeChatReport(report) && reportAction?.actorAccountID !== CONST.ACCOUNT_ID.CONCIERGE @@ -6007,7 +6029,7 @@ function canLeaveInvoiceRoom(report: OnyxEntry): boolean { */ function canLeaveRoom(report: OnyxEntry, isPolicyEmployee: boolean): boolean { if (isInvoiceRoom(report)) { - if (isArchivedRoom(report)) { + if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { return false; } @@ -6078,7 +6100,7 @@ function getWhisperDisplayNames(participantAccountIDs?: number[]): string | unde * Show subscript on workspace chats / threads and expense requests */ function shouldReportShowSubscript(report: OnyxEntry): boolean { - if (isArchivedRoom(report) && !isWorkspaceThread(report)) { + if (isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && !isWorkspaceThread(report)) { return false; } @@ -6225,7 +6247,7 @@ function getAllWorkspaceReports(policyID: string): Array> { function shouldDisableRename(report: OnyxEntry): boolean { if ( isDefaultRoom(report) || - isArchivedRoom(report) || + isArchivedRoom(report, getReportNameValuePair(report?.reportID)) || isPublicRoom(report) || isThread(report) || isMoneyRequest(report) || @@ -6253,14 +6275,14 @@ function shouldDisableRename(report: OnyxEntry): boolean { * @param policy - the workspace the report is on, null if the user isn't a member of the workspace */ function canEditWriteCapability(report: OnyxEntry, policy: OnyxEntry): boolean { - return PolicyUtils.isPolicyAdmin(policy) && !isAdminRoom(report) && !isArchivedRoom(report) && !isThread(report) && !isInvoiceRoom(report); + return PolicyUtils.isPolicyAdmin(policy) && !isAdminRoom(report) && !isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && !isThread(report) && !isInvoiceRoom(report); } /** * @param policy - the workspace the report is on, null if the user isn't a member of the workspace */ function canEditRoomVisibility(report: OnyxEntry, policy: OnyxEntry): boolean { - return PolicyUtils.isPolicyAdmin(policy) && !isArchivedRoom(report); + return PolicyUtils.isPolicyAdmin(policy) && !isArchivedRoom(report, getReportNameValuePair(report?.reportID)); } /** @@ -6466,7 +6488,7 @@ function isDeprecatedGroupDM(report: OnyxEntry): boolean { !isTaskReport(report) && !isInvoiceReport(report) && !isMoneyRequestReport(report) && - !isArchivedRoom(report) && + !isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && !Object.values(CONST.REPORT.CHAT_TYPE).some((chatType) => chatType === getChatType(report)) && Object.keys(report.participants ?? {}) .map(Number) @@ -6530,7 +6552,7 @@ function getRoom(type: ValueOf, policyID: string) function canEditReportDescription(report: OnyxEntry, policy: OnyxEntry): boolean { return ( !isMoneyRequestReport(report) && - !isArchivedRoom(report) && + !isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && isChatRoom(report) && !isChatThread(report) && !isEmpty(policy) && @@ -6679,7 +6701,7 @@ function shouldDisableThread(reportAction: OnyxInputOrEntry, repor const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction); const isIOUAction = ReportActionsUtils.isMoneyRequestAction(reportAction); const isWhisperAction = ReportActionsUtils.isWhisperAction(reportAction) || ReportActionsUtils.isActionableTrackExpense(reportAction); - const isArchivedReport = isArchivedRoom(getReportOrDraftReport(reportID)); + const isArchivedReport = isArchivedRoom(getReportOrDraftReport(reportID), getReportNameValuePair(reportID)); const isActionDisabled = CONST.REPORT.ACTIONS.THREAD_DISABLED.some((action: string) => action === reportAction?.actionName); return ( @@ -7401,6 +7423,7 @@ export { hasOnlyNonReimbursableTransactions, getMostRecentlyVisitedReport, getReport, + getReportNameValuePair, }; export type { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 3151f522d8007..1e4bf9798bdb9 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -177,13 +177,14 @@ function getOrderedReportIDs( const isPinned = report?.isPinned ?? false; const reportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); + const reportNameValuePairs = ReportUtils.getReportNameValuePair(report?.reportID); if (isPinned || ReportUtils.requiresAttentionFromCurrentUser(report, reportAction)) { pinnedAndGBRReports.push(miniReport); } else if (report?.hasErrorsOtherThanFailedReceipt) { errorReports.push(miniReport); } else if (hasValidDraftComment(report?.reportID ?? '-1')) { draftReports.push(miniReport); - } else if (ReportUtils.isArchivedRoom(report)) { + } else if (ReportUtils.isArchivedRoom(report, reportNameValuePairs)) { archivedReports.push(miniReport); } else { nonArchivedReports.push(miniReport); @@ -293,7 +294,8 @@ function getOptionData({ result.isTaskReport = ReportUtils.isTaskReport(report); result.isInvoiceReport = ReportUtils.isInvoiceReport(report); result.parentReportAction = parentReportAction; - result.isArchivedRoom = ReportUtils.isArchivedRoom(report); + const reportNameValuePairs = ReportUtils.getReportNameValuePair(report?.reportID); + result.isArchivedRoom = ReportUtils.isArchivedRoom(report, reportNameValuePairs); result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); result.isExpenseRequest = ReportUtils.isExpenseRequest(report); result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index d72e7d5c83ba1..cfad80877919e 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6202,7 +6202,8 @@ function canApproveIOU( const isOpenExpenseReport = isPolicyExpenseChat && ReportUtils.isOpenExpenseReport(iouReport); const isApproved = ReportUtils.isReportApproved(iouReport); const iouSettled = ReportUtils.isSettled(iouReport?.reportID); - const isArchivedReport = ReportUtils.isArchivedRoom(iouReport); + const reportNameValuePairs = ReportUtils.getReportNameValuePair(iouReport?.reportID); + const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs); return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport; } @@ -6213,7 +6214,8 @@ function canIOUBePaid( policy: OnyxTypes.OnyxInputOrEntry, ) { const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport); - const isChatReportArchived = ReportUtils.isArchivedRoom(chatReport); + const reportNameValuePairs = ReportUtils.getReportNameValuePair(chatReport?.reportID); + const isChatReportArchived = ReportUtils.isArchivedRoom(chatReport, reportNameValuePairs); const iouSettled = ReportUtils.isSettled(iouReport?.reportID); if (isEmptyObject(iouReport)) { diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 964f5be0129bc..5b62319e993fe 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1100,7 +1100,8 @@ function canModifyTask(taskReport: OnyxEntry, sessionAccountID } const parentReport = getParentReport(taskReport); - if (ReportUtils.isArchivedRoom(parentReport)) { + const reportNameValuePairs = ReportUtils.getReportNameValuePair(parentReport?.reportID); + if (ReportUtils.isArchivedRoom(parentReport, reportNameValuePairs)) { return false; } diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index ea9746aaeb77a..151ad2753a751 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -86,6 +86,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD // The app would crash due to subscribing to the entire report collection if parentReportID is an empty string. So we should have a fallback ID here. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID || '-1'}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const {reportActions} = usePaginatedReportActions(report.reportID || '-1'); const transactionThreadReportID = useMemo( @@ -108,7 +109,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const isUserCreatedPolicyRoom = useMemo(() => ReportUtils.isUserCreatedPolicyRoom(report), [report]); const isDefaultRoom = useMemo(() => ReportUtils.isDefaultRoom(report), [report]); const isChatThread = useMemo(() => ReportUtils.isChatThread(report), [report]); - const isArchivedRoom = useMemo(() => ReportUtils.isArchivedRoom(report), [report]); + const isArchivedRoom = useMemo(() => ReportUtils.isArchivedRoom(report, reportNameValuePairs), [report, reportNameValuePairs]); const isMoneyRequestReport = useMemo(() => ReportUtils.isMoneyRequestReport(report), [report]); const isMoneyRequest = useMemo(() => ReportUtils.isMoneyRequest(report), [report]); const isInvoiceReport = useMemo(() => ReportUtils.isInvoiceReport(report), [report]); @@ -503,7 +504,9 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const canHoldUnholdReportAction = ReportUtils.canHoldUnholdReportAction(parentReportAction); const shouldShowHoldAction = - caseID !== CASES.MONEY_REPORT && (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) && !ReportUtils.isArchivedRoom(parentReport); + caseID !== CASES.MONEY_REPORT && + (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) && + !ReportUtils.isArchivedRoom(parentReport, ReportUtils.getReportNameValuePair(parentReport?.reportID)); const canJoin = ReportUtils.canJoinChat(report, parentReportAction, policy); diff --git a/src/pages/ReportParticipantsPage.tsx b/src/pages/ReportParticipantsPage.tsx index 6fee6077b721d..0f5dae69cc5b0 100755 --- a/src/pages/ReportParticipantsPage.tsx +++ b/src/pages/ReportParticipantsPage.tsx @@ -3,7 +3,7 @@ import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {InteractionManager, View} from 'react-native'; import type {TextInput} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx, withOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import Badge from '@components/Badge'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; @@ -56,6 +56,7 @@ function ReportParticipantsPage({report, personalDetails, session}: ReportPartic const selectionListRef = useRef(null); const textInputRef = useRef(null); const currentUserAccountID = Number(session?.accountID); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const isCurrentUserAdmin = ReportUtils.isGroupChatAdmin(report, currentUserAccountID); const isGroupChat = useMemo(() => ReportUtils.isGroupChat(report), [report]); const isFocused = useIsFocused(); @@ -317,7 +318,7 @@ function ReportParticipantsPage({report, personalDetails, session}: ReportPartic style={[styles.defaultModalContainer]} testID={ReportParticipantsPage.displayName} > - + Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)) : undefined} diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 31bd21adce4cb..6399b1e26f1ca 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -189,6 +189,7 @@ function ReportActionItem({ const draftMessage = useMemo(() => getDraftMessage(reportActionDrafts, report.reportID, action), [action, report.reportID, reportActionDrafts]); const theme = useTheme(); const styles = useThemeStyles(); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const StyleUtils = useStyleUtils(); const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT; const [isContextMenuActive, setIsContextMenuActive] = useState(() => ReportActionContextMenu.isActiveReportAction(action.reportActionID)); @@ -702,7 +703,8 @@ function ReportActionItem({ index={index} ref={textInputRef} shouldDisableEmojiPicker={ - (ReportUtils.chatIncludesConcierge(report) && User.isBlockedFromConcierge(blockedFromConcierge)) || ReportUtils.isArchivedRoom(report) + (ReportUtils.chatIncludesConcierge(report) && User.isBlockedFromConcierge(blockedFromConcierge)) || + ReportUtils.isArchivedRoom(report, reportNameValuePairs) } isGroupPolicyReport={!!report?.policyID && report.policyID !== CONST.POLICY.ID_FAKE} /> diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 1ea58028c69f9..b8ff8b690d8eb 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -5,6 +5,7 @@ import type {DebouncedFunc} from 'lodash'; import React, {memo, useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {DeviceEventEmitter, InteractionManager} from 'react-native'; import type {LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent, StyleProp, ViewStyle} from 'react-native'; +import {useOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import Animated, {useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; import InvertedFlatList from '@components/InvertedFlatList'; @@ -26,6 +27,7 @@ import type {AuthScreensParamList} from '@navigation/types'; import variables from '@styles/variables'; import * as Report from '@userActions/Report'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; @@ -165,6 +167,7 @@ function ReportActionsList({ const {translate} = useLocalize(); const {isSmallScreenWidth, windowHeight} = useWindowDimensions(); const {isOffline} = useNetwork(); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const route = useRoute>(); const opacity = useSharedValue(0); const reportScrollManager = useReportScrollManager(); @@ -591,7 +594,10 @@ function ReportActionsList({ // Native mobile does not render updates flatlist the changes even though component did update called. // To notify there something changes we can use extraData prop to flatlist - const extraData = useMemo(() => [isSmallScreenWidth ? currentUnreadMarker : undefined, ReportUtils.isArchivedRoom(report)], [currentUnreadMarker, isSmallScreenWidth, report]); + const extraData = useMemo( + () => [isSmallScreenWidth ? currentUnreadMarker : undefined, ReportUtils.isArchivedRoom(report, reportNameValuePairs)], + [currentUnreadMarker, isSmallScreenWidth, report, reportNameValuePairs], + ); const hideComposer = !ReportUtils.canUserPerformWriteAction(report); const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(personalDetailsList, report, currentUserPersonalDetails.accountID) && !isComposerFullSize; const canShowHeader = isOffline || hasHeaderRendered.current; diff --git a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx index 126c24ac8a315..e6ba4858ad8b3 100644 --- a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx +++ b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx @@ -1,7 +1,7 @@ import React, {useEffect, useMemo} from 'react'; import type {ComponentType, ForwardedRef, RefAttributes} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx, withOnyx} from 'react-native-onyx'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePrevious from '@hooks/usePrevious'; @@ -34,6 +34,7 @@ export default function (pageTitle: TranslationPaths) { const {translate} = useLocalize(); const {isOffline} = useNetwork(); const {route, report, session} = props; + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const accountID = ('accountID' in route.params && route.params.accountID) || ''; const isPrivateNotesFetchTriggered = report.isLoadingPrivateNotes !== undefined; const prevIsOffline = usePrevious(isOffline); @@ -57,7 +58,7 @@ export default function (pageTitle: TranslationPaths) { // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = useMemo(() => { // Show not found view if the report is archived, or if the note is not of current user or if report is a self DM. - if (ReportUtils.isArchivedRoom(report) || isOtherUserNote || ReportUtils.isSelfDM(report)) { + if (ReportUtils.isArchivedRoom(report, reportNameValuePairs) || isOtherUserNote || ReportUtils.isSelfDM(report)) { return true; } @@ -68,7 +69,7 @@ export default function (pageTitle: TranslationPaths) { // As notes being empty and not loading is a valid case, show not found view only in offline mode. return isOffline; - }, [report, isOtherUserNote, shouldShowFullScreenLoadingIndicator, isPrivateNotesUndefined, isReconnecting, isOffline]); + }, [report, isOtherUserNote, shouldShowFullScreenLoadingIndicator, isPrivateNotesUndefined, isReconnecting, isOffline, reportNameValuePairs]); if (shouldShowFullScreenLoadingIndicator) { return ; diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 03f8c4e280a24..ab18013d6b233 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -4,7 +4,7 @@ import type {ForwardedRef, RefAttributes} from 'react'; import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react'; import {View} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx, withOnyx} from 'react-native-onyx'; import type {SvgProps} from 'react-native-svg'; import FloatingActionButton from '@components/FloatingActionButton'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -175,6 +175,7 @@ function FloatingActionButtonAndPopover( ) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${quickActionReport?.reportID ?? -1}`); const [isCreateMenuActive, setIsCreateMenuActive] = useState(false); const fabRef = useRef(null); const {isSmallScreenWidth, windowHeight} = useWindowDimensions(); @@ -238,7 +239,7 @@ function FloatingActionButtonAndPopover( onSelected(); }; - const isValidReport = !(isEmptyObject(quickActionReport) || ReportUtils.isArchivedRoom(quickActionReport)); + const isValidReport = !(isEmptyObject(quickActionReport) || ReportUtils.isArchivedRoom(quickActionReport, reportNameValuePairs)); const quickActionReportID = isValidReport ? quickActionReport?.reportID ?? '-1' : ReportUtils.generateReportID(); switch (quickAction?.action) { diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index ae38d4b278e4e..f0e78c7000496 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -1,7 +1,7 @@ import {useFocusEffect} from '@react-navigation/native'; import React, {useCallback, useEffect, useMemo, useRef} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx, withOnyx} from 'react-native-onyx'; import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types'; import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; @@ -78,6 +78,7 @@ function IOURequestStepAmount({ const focusTimeoutRef = useRef(null); const isSaveButtonPressed = useRef(false); const iouRequestType = getRequestType(transaction); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const isEditing = action === CONST.IOU.ACTION.EDIT; const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; @@ -94,8 +95,8 @@ function IOURequestStepAmount({ return false; } - return !(ReportUtils.isArchivedRoom(report) || ReportUtils.isPolicyExpenseChat(report)); - }, [report, skipConfirmation]); + return !(ReportUtils.isArchivedRoom(report, reportNameValuePairs) || ReportUtils.isPolicyExpenseChat(report)); + }, [report, skipConfirmation, reportNameValuePairs]); useFocusEffect( useCallback(() => { @@ -182,7 +183,7 @@ function IOURequestStepAmount({ // If a reportID exists in the report object, it's because the user started this flow from using the + button in the composer // inside a report. In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. - if (report?.reportID && !ReportUtils.isArchivedRoom(report)) { + if (report?.reportID && !ReportUtils.isArchivedRoom(report, reportNameValuePairs)) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? -1; diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 9235c3293a6d8..64d9f200879b7 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -5,7 +5,7 @@ import {View} from 'react-native'; import type {ScrollView as RNScrollView} from 'react-native'; import type {RenderItemParams} from 'react-native-draggable-flatlist/lib/typescript/types'; import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx, withOnyx} from 'react-native-onyx'; import Button from '@components/Button'; import DistanceRequestFooter from '@components/DistanceRequest/DistanceRequestFooter'; import DistanceRequestRenderItem from '@components/DistanceRequest/DistanceRequestRenderItem'; @@ -74,6 +74,7 @@ function IOURequestStepDistance({ const styles = useThemeStyles(); const {isOffline} = useNetwork(); const {translate} = useLocalize(); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const [optimisticWaypoints, setOptimisticWaypoints] = useState(null); const waypoints = useMemo(() => optimisticWaypoints ?? transaction?.comment?.waypoints ?? {waypoint0: {}, waypoint1: {}}, [optimisticWaypoints, transaction]); @@ -110,8 +111,10 @@ function IOURequestStepDistance({ return false; } - return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); - }, [report, skipConfirmation, policy]); + return ( + !ReportUtils.isArchivedRoom(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))) + ); + }, [report, skipConfirmation, policy, reportNameValuePairs]); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); if (shouldSkipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { @@ -224,7 +227,7 @@ function IOURequestStepDistance({ // If a reportID exists in the report object, it's because the user started this flow from using the + button in the composer // inside a report. In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. - if (report?.reportID && !ReportUtils.isArchivedRoom(report)) { + if (report?.reportID && !ReportUtils.isArchivedRoom(report, reportNameValuePairs)) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? -1; @@ -316,6 +319,7 @@ function IOURequestStepDistance({ navigateToParticipantPage, navigateToConfirmationPage, policy, + reportNameValuePairs, ]); const getError = () => { diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 9301387d5c516..0c43640ec8467 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -2,7 +2,7 @@ import {useFocusEffect} from '@react-navigation/core'; import React, {useCallback, useMemo, useRef, useState} from 'react'; import {ActivityIndicator, Alert, AppState, InteractionManager, View} from 'react-native'; import {Gesture, GestureDetector} from 'react-native-gesture-handler'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx, withOnyx} from 'react-native-onyx'; import {RESULTS} from 'react-native-permissions'; import Animated, {runOnJS, useAnimatedStyle, useSharedValue, withDelay, withSequence, withSpring, withTiming} from 'react-native-reanimated'; import type {Camera, PhotoFile, Point} from 'react-native-vision-camera'; @@ -62,6 +62,7 @@ function IOURequestStepScan({ const hasFlash = !!device?.hasFlash; const camera = useRef(null); const [flash, setFlash] = useState(false); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const [cameraPermissionStatus, setCameraPermissionStatus] = useState(null); const [didCapturePhoto, setDidCapturePhoto] = useState(false); @@ -76,8 +77,10 @@ function IOURequestStepScan({ return false; } - return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); - }, [report, skipConfirmation, policy]); + return ( + !ReportUtils.isArchivedRoom(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))) + ); + }, [report, skipConfirmation, policy, reportNameValuePairs]); const {translate} = useLocalize(); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index db03e539cdb56..2988e072335ae 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -1,6 +1,6 @@ import React, {useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState} from 'react'; import {ActivityIndicator, PanResponder, PixelRatio, View} from 'react-native'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx, withOnyx} from 'react-native-onyx'; import type Webcam from 'react-webcam'; import type {TupleToUnion} from 'type-fest'; import Hand from '@assets/images/hand.svg'; @@ -68,7 +68,7 @@ function IOURequestStepScan({ const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); const {isDraggingOver} = useContext(DragAndDropContext); - + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const [cameraPermissionState, setCameraPermissionState] = useState('prompt'); const [isFlashLightOn, toggleFlashlight] = useReducer((state) => !state, false); const [isTorchAvailable, setIsTorchAvailable] = useState(false); @@ -93,8 +93,10 @@ function IOURequestStepScan({ return false; } - return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); - }, [report, skipConfirmation, policy]); + return ( + !ReportUtils.isArchivedRoom(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))) + ); + }, [report, skipConfirmation, policy, reportNameValuePairs]); /** * On phones that have ultra-wide lens, react-webcam uses ultra-wide by default. diff --git a/src/pages/settings/Report/NotificationPreferencePage.tsx b/src/pages/settings/Report/NotificationPreferencePage.tsx index 39e008c2beeef..9e50644cce992 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.tsx +++ b/src/pages/settings/Report/NotificationPreferencePage.tsx @@ -1,5 +1,6 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React from 'react'; +import {useOnyx} from 'react-native-onyx'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; @@ -12,13 +13,15 @@ import withReportOrNotFound from '@pages/home/report/withReportOrNotFound'; import type {WithReportOrNotFoundProps} from '@pages/home/report/withReportOrNotFound'; import * as ReportActions from '@userActions/Report'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import type SCREENS from '@src/SCREENS'; type NotificationPreferencePageProps = WithReportOrNotFoundProps & StackScreenProps; function NotificationPreferencePage({report}: NotificationPreferencePageProps) { const {translate} = useLocalize(); - const shouldDisableNotificationPreferences = ReportUtils.isArchivedRoom(report) || ReportUtils.isSelfDM(report); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID || -1}`); + const shouldDisableNotificationPreferences = ReportUtils.isArchivedRoom(report, reportNameValuePairs) || ReportUtils.isSelfDM(report); const notificationPreferenceOptions = Object.values(CONST.REPORT.NOTIFICATION_PREFERENCE) .filter((pref) => pref !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) .map((preference) => ({ diff --git a/src/pages/settings/Report/ReportSettingsPage.tsx b/src/pages/settings/Report/ReportSettingsPage.tsx index d88df4dcf9cf3..6e1ab9a617378 100644 --- a/src/pages/settings/Report/ReportSettingsPage.tsx +++ b/src/pages/settings/Report/ReportSettingsPage.tsx @@ -1,6 +1,7 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useMemo} from 'react'; import {View} from 'react-native'; +import {useOnyx} from 'react-native-onyx'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; @@ -15,6 +16,7 @@ import type {ReportSettingsNavigatorParamList} from '@navigation/types'; import withReportOrNotFound from '@pages/home/report/withReportOrNotFound'; import type {WithReportOrNotFoundProps} from '@pages/home/report/withReportOrNotFound'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; @@ -25,11 +27,12 @@ function ReportSettingsPage({report, policies}: ReportSettingsPageProps) { const reportID = report?.reportID ?? '-1'; const styles = useThemeStyles(); const {translate} = useLocalize(); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`); // The workspace the report is on, null if the user isn't a member of the workspace const linkedWorkspace = useMemo(() => Object.values(policies ?? {}).find((policy) => policy && policy.id === report?.policyID), [policies, report?.policyID]); const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); - const shouldDisableSettings = isEmptyObject(report) || ReportUtils.isArchivedRoom(report) || ReportUtils.isSelfDM(report); + const shouldDisableSettings = isEmptyObject(report) || ReportUtils.isArchivedRoom(report, reportNameValuePairs) || ReportUtils.isSelfDM(report); const notificationPreference = report?.notificationPreference && report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN ? translate(`notificationPreferencesPage.notificationPreferences.${report.notificationPreference}`) diff --git a/src/pages/settings/Report/VisibilityPage.tsx b/src/pages/settings/Report/VisibilityPage.tsx index 9bcf3b05e83a7..76ba076138c86 100644 --- a/src/pages/settings/Report/VisibilityPage.tsx +++ b/src/pages/settings/Report/VisibilityPage.tsx @@ -1,5 +1,6 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useCallback, useMemo, useState} from 'react'; +import {useOnyx} from 'react-native-onyx'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import ConfirmModal from '@components/ConfirmModal'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; @@ -13,6 +14,7 @@ import type {WithReportOrNotFoundProps} from '@pages/home/report/withReportOrNot import withReportOrNotFound from '@pages/home/report/withReportOrNotFound'; import * as ReportActions from '@userActions/Report'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import type SCREENS from '@src/SCREENS'; import type {RoomVisibility} from '@src/types/onyx/Report'; @@ -20,8 +22,9 @@ type VisibilityProps = WithReportOrNotFoundProps & StackScreenProps; export default ReportNameValuePairs; From a6e827114ef1a345d06d56d71136335f448ee093 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Fri, 12 Jul 2024 18:59:40 +0700 Subject: [PATCH 2/8] lint fix --- src/components/ShowContextMenuContext.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ShowContextMenuContext.ts b/src/components/ShowContextMenuContext.ts index 5df8bc123bba3..5e4cb8dfcc90e 100644 --- a/src/components/ShowContextMenuContext.ts +++ b/src/components/ShowContextMenuContext.ts @@ -17,7 +17,7 @@ type ShowContextMenuContextProps = { checkIfContextMenuActive: () => void; }; -const ShowContextMenuContext = createContext({ +const ShowContextMenuContext = createContext({ anchor: null, report: undefined, action: undefined, From c6a8c74107be150c6d2db6b51a93f5df84e88756 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Fri, 12 Jul 2024 19:08:13 +0700 Subject: [PATCH 3/8] add reportNameValuePairs to context --- .../AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx | 4 ++-- .../HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx | 4 ++-- .../HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx | 4 ++-- .../HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx | 4 ++-- src/components/ShowContextMenuContext.ts | 4 +++- src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx | 4 ++-- src/pages/home/report/ReportActionItem.tsx | 3 ++- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index 7a0d6d522e335..d68c339ae6409 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -41,7 +41,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', dow return ( - {({anchor, report, action, checkIfContextMenuActive}) => ( + {({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive}) => ( { @@ -60,7 +60,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', dow report?.reportID ?? '-1', action, checkIfContextMenuActive, - ReportUtils.isArchivedRoom(report, ReportUtils.getReportNameValuePair(report?.reportID)), + ReportUtils.isArchivedRoom(report, reportNameValuePairs), ) } shouldUseHapticsOnLongPress diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx index 76046a4a895d2..897b386279c91 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx @@ -78,7 +78,7 @@ function ImageRenderer({tnode}: ImageRendererProps) { thumbnailImageComponent ) : ( - {({anchor, report, action, checkIfContextMenuActive}) => ( + {({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive}) => ( {({reportID, accountID, type}) => ( - {({anchor, report, action, checkIfContextMenuActive}) => ( + {({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive}) => ( @@ -93,7 +93,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona report?.reportID ?? '-1', action, checkIfContextMenuActive, - ReportUtils.isArchivedRoom(report, ReportUtils.getReportNameValuePair(report?.reportID)), + ReportUtils.isArchivedRoom(report, reportNameValuePairs), ) } onPress={(event) => { diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx index 396c64ab53569..849e93a672003 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx @@ -34,7 +34,7 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d return ( - {({anchor, report, action, checkIfContextMenuActive}) => ( + {({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive}) => ( {})} onPressIn={onPressIn} @@ -46,7 +46,7 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d report?.reportID ?? '-1', action, checkIfContextMenuActive, - ReportUtils.isArchivedRoom(report, ReportUtils.getReportNameValuePair(report?.reportID)), + ReportUtils.isArchivedRoom(report, reportNameValuePairs), ) } shouldUseHapticsOnLongPress diff --git a/src/components/ShowContextMenuContext.ts b/src/components/ShowContextMenuContext.ts index 5e4cb8dfcc90e..b3050f986be19 100644 --- a/src/components/ShowContextMenuContext.ts +++ b/src/components/ShowContextMenuContext.ts @@ -7,11 +7,12 @@ import * as ReportUtils from '@libs/ReportUtils'; import * as ReportActionContextMenu from '@pages/home/report/ContextMenu/ReportActionContextMenu'; import type {ContextMenuAnchor} from '@pages/home/report/ContextMenu/ReportActionContextMenu'; import CONST from '@src/CONST'; -import type {Report, ReportAction} from '@src/types/onyx'; +import type {Report, ReportAction, ReportNameValuePairs} from '@src/types/onyx'; type ShowContextMenuContextProps = { anchor: ContextMenuAnchor; report: OnyxEntry; + reportNameValuePairs: OnyxEntry; action: OnyxEntry; transactionThreadReport?: OnyxEntry; checkIfContextMenuActive: () => void; @@ -20,6 +21,7 @@ type ShowContextMenuContextProps = { const ShowContextMenuContext = createContext({ anchor: null, report: undefined, + reportNameValuePairs: undefined, action: undefined, transactionThreadReport: undefined, checkIfContextMenuActive: () => {}, diff --git a/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx b/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx index 55812776a6c64..0b7aba132353e 100644 --- a/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx +++ b/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx @@ -40,7 +40,7 @@ function VideoPlayerThumbnail({thumbnailUrl, onPress, accessibilityLabel}: Video )} - {({anchor, report, action, checkIfContextMenuActive}) => ( + {({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive}) => ( ({ anchor: popoverAnchorRef.current, report, + reportNameValuePairs, action, transactionThreadReport, checkIfContextMenuActive: toggleContextMenuFromActiveReportAction, }), - [report, action, toggleContextMenuFromActiveReportAction, transactionThreadReport], + [report, action, toggleContextMenuFromActiveReportAction, transactionThreadReport, reportNameValuePairs], ); const attachmentContextValue = useMemo(() => ({reportID: report.reportID, type: CONST.ATTACHMENT_TYPE.REPORT}), [report.reportID]); From f496a259cb48272111121f07304231cb08edf554 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Fri, 12 Jul 2024 19:10:07 +0700 Subject: [PATCH 4/8] lint fix --- .../BaseAnchorForAttachmentsOnly.tsx | 9 +-------- .../HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx | 9 +-------- .../HTMLRenderers/MentionUserRenderer.tsx | 9 +-------- .../HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx | 9 +-------- .../VideoPlayerPreview/VideoPlayerThumbnail.tsx | 9 +-------- 5 files changed, 5 insertions(+), 40 deletions(-) diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index d68c339ae6409..b9aeceeb3621b 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -54,14 +54,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', dow onPressIn={onPressIn} onPressOut={onPressOut} onLongPress={(event) => - showContextMenuForReport( - event, - anchor, - report?.reportID ?? '-1', - action, - checkIfContextMenuActive, - ReportUtils.isArchivedRoom(report, reportNameValuePairs), - ) + showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs)) } shouldUseHapticsOnLongPress accessibilityLabel={displayName} diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx index 897b386279c91..1e73cce1630ff 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx @@ -94,14 +94,7 @@ function ImageRenderer({tnode}: ImageRendererProps) { } }} onLongPress={(event) => - showContextMenuForReport( - event, - anchor, - report?.reportID ?? '-1', - action, - checkIfContextMenuActive, - ReportUtils.isArchivedRoom(report, reportNameValuePairs), - ) + showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs)) } shouldUseHapticsOnLongPress accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON} diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index e51bbe3ad96c4..ffab2434c83cf 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -87,14 +87,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona - showContextMenuForReport( - event, - anchor, - report?.reportID ?? '-1', - action, - checkIfContextMenuActive, - ReportUtils.isArchivedRoom(report, reportNameValuePairs), - ) + showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs)) } onPress={(event) => { event.preventDefault(); diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx index 849e93a672003..14666798e8c70 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx @@ -40,14 +40,7 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d onPressIn={onPressIn} onPressOut={onPressOut} onLongPress={(event) => - showContextMenuForReport( - event, - anchor, - report?.reportID ?? '-1', - action, - checkIfContextMenuActive, - ReportUtils.isArchivedRoom(report, reportNameValuePairs), - ) + showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs)) } shouldUseHapticsOnLongPress role={CONST.ROLE.PRESENTATION} diff --git a/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx b/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx index 0b7aba132353e..5900e3097b960 100644 --- a/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx +++ b/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx @@ -49,14 +49,7 @@ function VideoPlayerThumbnail({thumbnailUrl, onPress, accessibilityLabel}: Video onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} onLongPress={(event) => - showContextMenuForReport( - event, - anchor, - report?.reportID ?? '-1', - action, - checkIfContextMenuActive, - ReportUtils.isArchivedRoom(report, reportNameValuePairs), - ) + showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs)) } shouldUseHapticsOnLongPress > From fd2c349895022c17ed1663a9a523ae4580a7efdf Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Fri, 12 Jul 2024 19:13:35 +0700 Subject: [PATCH 5/8] lint fix --- src/libs/ReportUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ab4af7adba662..3f9440c5fbd71 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -639,7 +639,6 @@ function getReport(reportID: string): OnyxEntry { * Returns the report */ function getReportNameValuePair(reportID?: string): OnyxEntry { - // ?? ([] as ReportNameValuePairs[]) return allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID ?? -1}`]; } From 631c9657e0264252ea9f3a2acb6a5207af351629 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Fri, 12 Jul 2024 19:24:30 +0700 Subject: [PATCH 6/8] lint fix --- src/libs/ReportUtils.ts | 1 + src/pages/ReportDetailsPage.tsx | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 3f9440c5fbd71..34a6bc608da93 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2475,6 +2475,7 @@ function getPolicyExpenseChatName(report: OnyxEntry, policy?: OnyxEntry< const login = personalDetails ? personalDetails.login : null; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const reportOwnerDisplayName = getDisplayNameForParticipant(ownerAccountID) || login || report?.reportName; + // If the policy expense chat is owned by this user, use the name of the policy as the report name. if (report?.isOwnPolicyExpenseChat) { return getPolicyName(report, false, policy); diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 151ad2753a751..b890e2e0dd136 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -87,6 +87,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID || '-1'}`); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); + const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.parentReportID ?? -1}`); const {reportActions} = usePaginatedReportActions(report.reportID || '-1'); const transactionThreadReportID = useMemo( @@ -506,7 +507,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const shouldShowHoldAction = caseID !== CASES.MONEY_REPORT && (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) && - !ReportUtils.isArchivedRoom(parentReport, ReportUtils.getReportNameValuePair(parentReport?.reportID)); + !ReportUtils.isArchivedRoom(parentReport, parentReportNameValuePairs); const canJoin = ReportUtils.canJoinChat(report, parentReportAction, policy); From 31df927305511d53f4f8b5d6d4132d9293cce843 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Mon, 15 Jul 2024 14:17:43 +0700 Subject: [PATCH 7/8] resolve comment --- src/libs/OptionsListUtils.ts | 4 +- src/libs/ReportUtils.ts | 82 +++++++++++------------------------- src/libs/SidebarUtils.ts | 8 ++-- src/libs/actions/IOU.ts | 4 +- src/libs/actions/Task.ts | 2 +- 5 files changed, 34 insertions(+), 66 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 55a82ae8477d5..dbed46598d85a 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -663,7 +663,7 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails // some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action const lastOriginalReportAction = lastReportActions[reportID] ?? null; let lastMessageTextFromReport = ''; - const reportNameValuePairs = ReportUtils.getReportNameValuePair(report?.reportID); + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); if (ReportUtils.isArchivedRoom(report, reportNameValuePairs)) { const archiveReason = @@ -789,7 +789,7 @@ function createOption( let reportName; result.participantsList = personalDetailList; result.isOptimisticPersonalDetail = personalDetail?.isOptimisticPersonalDetail; - const reportNameValuePairs = ReportUtils.getReportNameValuePair(report?.reportID); + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); if (report) { result.isChatRoom = ReportUtils.isChatRoom(report); result.isDefaultRoom = ReportUtils.isDefaultRoom(report); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 908ca47d5507a..e29a2c14e3c4b 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -636,7 +636,7 @@ function getReport(reportID: string): OnyxEntry { /** * Returns the report */ -function getReportNameValuePair(reportID?: string): OnyxEntry { +function getReportNameValuePairs(reportID?: string): OnyxEntry { return allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID ?? -1}`]; } @@ -1299,7 +1299,7 @@ function isArchivedRoom(report: OnyxInputOrEntry, reportNameValuePairs?: function isArchivedRoomWithID(reportID?: string) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const report = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID || -1}`]; - return isArchivedRoom(report, getReportNameValuePair(reportID)); + return isArchivedRoom(report, getReportNameValuePairs(reportID)); } /** @@ -1650,40 +1650,6 @@ function canDeleteReportAction(reportAction: OnyxInputOrEntry, rep } /** -<<<<<<< HEAD - * Get welcome message based on room type - */ -function getRoomWelcomeMessage(report: OnyxEntry): WelcomeMessage { - const welcomeMessage: WelcomeMessage = {showReportName: true}; - const workspaceName = getPolicyName(report); - - if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfArchivedRoomPartOne'); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfArchivedRoomPartTwo'); - } else if (isDomainRoom(report)) { - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryDomainRoomPartOne', {domainRoom: report?.reportName ?? ''}); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryDomainRoomPartTwo'); - } else if (isAdminRoom(report)) { - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartOne', {workspaceName}); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartTwo'); - } else if (isAnnounceRoom(report)) { - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartOne', {workspaceName}); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartTwo', {workspaceName}); - } else if (isInvoiceRoom(report)) { - welcomeMessage.showReportName = false; - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryInvoiceRoom'); - } else { - // Message for user created rooms or other room types. - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryUserRoomPartOne'); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryUserRoomPartTwo'); - } - - return welcomeMessage; -} - -/** -======= ->>>>>>> main * Returns true if Concierge is one of the chat participants (1:1 as well as group chats) */ function chatIncludesConcierge(report: Partial>): boolean { @@ -2079,7 +2045,7 @@ function getIcons( }; return [domainIcon]; } - if (isAdminRoom(report) || isAnnounceRoom(report) || isChatRoom(report) || isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { + if (isAdminRoom(report) || isAnnounceRoom(report) || isChatRoom(report) || isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { const icons = [getWorkspaceIcon(report, policy)]; if (isInvoiceRoom(report)) { @@ -2395,8 +2361,8 @@ function requiresAttentionFromCurrentUser(optionOrReport: OnyxEntry | Op } if ( - isArchivedRoom(optionOrReport, getReportNameValuePair(optionOrReport?.reportID)) || - isArchivedRoom(getReportOrDraftReport(optionOrReport.parentReportID), getReportNameValuePair(optionOrReport?.reportID)) + isArchivedRoom(optionOrReport, getReportNameValuePairs(optionOrReport?.reportID)) || + isArchivedRoom(getReportOrDraftReport(optionOrReport.parentReportID), getReportNameValuePairs(optionOrReport?.reportID)) ) { return false; } @@ -2490,7 +2456,7 @@ function getPolicyExpenseChatName(report: OnyxEntry, policy?: OnyxEntry< // If this user is not admin and this policy expense chat has been archived because of account merging, this must be an old workspace chat // of the account which was merged into the current user's account. Use the name of the policy as the name of the report. - if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { + if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { const lastAction = ReportActionsUtils.getLastVisibleAction(report?.reportID ?? '-1'); const archiveReason = ReportActionsUtils.isClosedAction(lastAction) ? ReportActionsUtils.getOriginalMessage(lastAction)?.reason : CONST.REPORT.ARCHIVE_REASON.DEFAULT; if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED && policyExpenseChatRole !== CONST.POLICY.ROLE.ADMIN) { @@ -3405,7 +3371,7 @@ function getReportName(report: OnyxEntry, policy?: OnyxEntry, pa if (isChatThread(report)) { if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction)) { formattedName = getTransactionReportName(parentReportAction); - if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { + if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { formattedName += ` (${Localize.translateLocal('common.archived')})`; } return formatReportLastMessageText(formattedName); @@ -3430,7 +3396,7 @@ function getReportName(report: OnyxEntry, policy?: OnyxEntry, pa if (isAdminRoom(report) || isUserCreatedPolicyRoom(report)) { return getAdminRoomInvitedParticipants(parentReportAction, parentReportActionMessage); } - if (parentReportActionMessage && isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { + if (parentReportActionMessage && isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { return `${parentReportActionMessage} (${Localize.translateLocal('common.archived')})`; } if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isModifiedExpenseAction(parentReportAction)) { @@ -3472,7 +3438,7 @@ function getReportName(report: OnyxEntry, policy?: OnyxEntry, pa formattedName = getInvoicesChatName(report); } - if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { + if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { formattedName += ` (${Localize.translateLocal('common.archived')})`; } @@ -3541,7 +3507,7 @@ function getChatRoomSubtitle(report: OnyxEntry): string | undefined { if ((isPolicyExpenseChat(report) && !!report?.isOwnPolicyExpenseChat) || isExpenseReport(report)) { return Localize.translateLocal('workspace.common.workspace'); } - if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { + if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { return report?.oldPolicyName ?? ''; } return getPolicyName(report); @@ -3567,7 +3533,7 @@ function getParentNavigationSubtitle(report: OnyxEntry): ParentNavigatio if (isInvoiceReport(report) || isInvoiceRoom(parentReport)) { let reportName = `${getPolicyName(parentReport)} & ${getInvoicePayerName(parentReport)}`; - if (isArchivedRoom(parentReport, getReportNameValuePair(parentReport?.reportID))) { + if (isArchivedRoom(parentReport, getReportNameValuePairs(parentReport?.reportID))) { reportName += ` (${Localize.translateLocal('common.archived')})`; } @@ -5318,7 +5284,7 @@ function isIOUOwnedByCurrentUser(report: OnyxEntry, allReportsDict?: Ony */ function canSeeDefaultRoom(report: OnyxEntry, policies: OnyxCollection, betas: OnyxEntry): boolean { // Include archived rooms - if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { + if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { return true; } @@ -5472,7 +5438,7 @@ function shouldReportBeInOptionList({ // So we allow showing rooms with no participants–in any other circumstances we should never have these reports with no participants in Onyx. !isChatRoom(report) && !isChatThread(report) && - !isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && + !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && !isMoneyRequestReport(report) && !isTaskReport(report) && !isSelfDM(report) && @@ -5547,7 +5513,7 @@ function shouldReportBeInOptionList({ } // Archived reports should always be shown when in default (most recent) mode. This is because you should still be able to access and search for the chats to find them. - if (isInDefaultMode && isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { + if (isInDefaultMode && isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { return true; } @@ -5709,7 +5675,7 @@ function canFlagReportAction(reportAction: OnyxInputOrEntry, repor function shouldShowFlagComment(reportAction: OnyxInputOrEntry, report: OnyxInputOrEntry): boolean { return ( canFlagReportAction(reportAction, report?.reportID) && - !isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && + !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && !chatIncludesChronos(report) && !isConciergeChatReport(report) && reportAction?.actorAccountID !== CONST.ACCOUNT_ID.CONCIERGE @@ -6023,7 +5989,7 @@ function canLeaveInvoiceRoom(report: OnyxEntry): boolean { */ function canLeaveRoom(report: OnyxEntry, isPolicyEmployee: boolean): boolean { if (isInvoiceRoom(report)) { - if (isArchivedRoom(report, getReportNameValuePair(report?.reportID))) { + if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { return false; } @@ -6094,7 +6060,7 @@ function getWhisperDisplayNames(participantAccountIDs?: number[]): string | unde * Show subscript on workspace chats / threads and expense requests */ function shouldReportShowSubscript(report: OnyxEntry): boolean { - if (isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && !isWorkspaceThread(report)) { + if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && !isWorkspaceThread(report)) { return false; } @@ -6241,7 +6207,7 @@ function getAllWorkspaceReports(policyID: string): Array> { function shouldDisableRename(report: OnyxEntry): boolean { if ( isDefaultRoom(report) || - isArchivedRoom(report, getReportNameValuePair(report?.reportID)) || + isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) || isPublicRoom(report) || isThread(report) || isMoneyRequest(report) || @@ -6269,14 +6235,14 @@ function shouldDisableRename(report: OnyxEntry): boolean { * @param policy - the workspace the report is on, null if the user isn't a member of the workspace */ function canEditWriteCapability(report: OnyxEntry, policy: OnyxEntry): boolean { - return PolicyUtils.isPolicyAdmin(policy) && !isAdminRoom(report) && !isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && !isThread(report) && !isInvoiceRoom(report); + return PolicyUtils.isPolicyAdmin(policy) && !isAdminRoom(report) && !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && !isThread(report) && !isInvoiceRoom(report); } /** * @param policy - the workspace the report is on, null if the user isn't a member of the workspace */ function canEditRoomVisibility(report: OnyxEntry, policy: OnyxEntry): boolean { - return PolicyUtils.isPolicyAdmin(policy) && !isArchivedRoom(report, getReportNameValuePair(report?.reportID)); + return PolicyUtils.isPolicyAdmin(policy) && !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)); } /** @@ -6482,7 +6448,7 @@ function isDeprecatedGroupDM(report: OnyxEntry): boolean { !isTaskReport(report) && !isInvoiceReport(report) && !isMoneyRequestReport(report) && - !isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && + !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && !Object.values(CONST.REPORT.CHAT_TYPE).some((chatType) => chatType === getChatType(report)) && Object.keys(report.participants ?? {}) .map(Number) @@ -6546,7 +6512,7 @@ function getRoom(type: ValueOf, policyID: string) function canEditReportDescription(report: OnyxEntry, policy: OnyxEntry): boolean { return ( !isMoneyRequestReport(report) && - !isArchivedRoom(report, getReportNameValuePair(report?.reportID)) && + !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && isChatRoom(report) && !isChatThread(report) && !isEmpty(policy) && @@ -6695,7 +6661,7 @@ function shouldDisableThread(reportAction: OnyxInputOrEntry, repor const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction); const isIOUAction = ReportActionsUtils.isMoneyRequestAction(reportAction); const isWhisperAction = ReportActionsUtils.isWhisperAction(reportAction) || ReportActionsUtils.isActionableTrackExpense(reportAction); - const isArchivedReport = isArchivedRoom(getReportOrDraftReport(reportID), getReportNameValuePair(reportID)); + const isArchivedReport = isArchivedRoom(getReportOrDraftReport(reportID), getReportNameValuePairs(reportID)); const isActionDisabled = CONST.REPORT.ACTIONS.THREAD_DISABLED.some((action: string) => action === reportAction?.actionName); return ( @@ -7416,7 +7382,7 @@ export { hasOnlyNonReimbursableTransactions, getMostRecentlyVisitedReport, getReport, - getReportNameValuePair, + getReportNameValuePairs, }; export type { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 89733acb6a661..37b9f3b881d9b 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -187,7 +187,7 @@ function getOrderedReportIDs( const isPinned = report?.isPinned ?? false; const reportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); - const reportNameValuePairs = ReportUtils.getReportNameValuePair(report?.reportID); + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); if (isPinned || ReportUtils.requiresAttentionFromCurrentUser(report, reportAction)) { pinnedAndGBRReports.push(miniReport); } else if (report?.hasErrorsOtherThanFailedReceipt) { @@ -304,7 +304,7 @@ function getOptionData({ result.isTaskReport = ReportUtils.isTaskReport(report); result.isInvoiceReport = ReportUtils.isInvoiceReport(report); result.parentReportAction = parentReportAction; - const reportNameValuePairs = ReportUtils.getReportNameValuePair(report?.reportID); + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); result.isArchivedRoom = ReportUtils.isArchivedRoom(report, reportNameValuePairs); result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); result.isExpenseRequest = ReportUtils.isExpenseRequest(report); @@ -557,7 +557,9 @@ function getRoomWelcomeMessage(report: OnyxEntry): WelcomeMessage { welcomeMessage.messageText = Parser.htmlToText(welcomeMessage.messageHtml); return welcomeMessage; } - if (ReportUtils.isArchivedRoom(report)) { + + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); + if (ReportUtils.isArchivedRoom(report, reportNameValuePairs)) { welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfArchivedRoomPartOne'); welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfArchivedRoomPartTwo'); } else if (ReportUtils.isDomainRoom(report)) { diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 21504dda65c46..d710c06c0d0d1 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6202,7 +6202,7 @@ function canApproveIOU( const isOpenExpenseReport = isPolicyExpenseChat && ReportUtils.isOpenExpenseReport(iouReport); const isApproved = ReportUtils.isReportApproved(iouReport); const iouSettled = ReportUtils.isSettled(iouReport?.reportID); - const reportNameValuePairs = ReportUtils.getReportNameValuePair(iouReport?.reportID); + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(iouReport?.reportID); const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs); return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport; @@ -6214,7 +6214,7 @@ function canIOUBePaid( policy: OnyxTypes.OnyxInputOrEntry, ) { const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport); - const reportNameValuePairs = ReportUtils.getReportNameValuePair(chatReport?.reportID); + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(chatReport?.reportID); const isChatReportArchived = ReportUtils.isArchivedRoom(chatReport, reportNameValuePairs); const iouSettled = ReportUtils.isSettled(iouReport?.reportID); diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 5b62319e993fe..8dcb6128b1430 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1100,7 +1100,7 @@ function canModifyTask(taskReport: OnyxEntry, sessionAccountID } const parentReport = getParentReport(taskReport); - const reportNameValuePairs = ReportUtils.getReportNameValuePair(parentReport?.reportID); + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(parentReport?.reportID); if (ReportUtils.isArchivedRoom(parentReport, reportNameValuePairs)) { return false; } From d89894c14e1a4868783b2b449a62d4c9ceedb944 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Mon, 15 Jul 2024 16:09:27 +0700 Subject: [PATCH 8/8] resolve comment --- src/pages/home/ReportScreen.tsx | 9 --------- src/pages/home/report/ReportFooter.tsx | 5 +---- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index f4b814ffc7fe5..d92012076fa88 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -69,9 +69,6 @@ type ReportScreenOnyxProps = { /** The policies which the user has access to */ policies: OnyxCollection; - /** Additional report details */ - reportNameValuePairs: OnyxEntry; - /** The report metadata loading states */ reportMetadata: OnyxEntry; }; @@ -116,7 +113,6 @@ function getParentReportAction(parentReportActions: OnyxEntry setIsComposerFocus(false)} report={report} reportMetadata={reportMetadata} - reportNameValuePairs={reportNameValuePairs} policy={policy} pendingAction={reportPendingAction} isComposerFullSize={!!isComposerFullSize} @@ -815,10 +810,6 @@ export default withCurrentReportID( isSidebarLoaded: { key: ONYXKEYS.IS_SIDEBAR_LOADED, }, - reportNameValuePairs: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${getReportID(route)}`, - allowStaleData: true, - }, reportMetadata: { key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_METADATA}${getReportID(route)}`, initialValue: { diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index c12a04b4059ae..8c13b0f8696c8 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -36,9 +36,6 @@ type ReportFooterProps = { /** Report metadata */ reportMetadata?: OnyxEntry; - /** Additional report details */ - reportNameValuePairs?: OnyxEntry; - /** The policy of the report */ policy: OnyxEntry; @@ -69,7 +66,6 @@ function ReportFooter({ pendingAction, report = {reportID: '-1'}, reportMetadata, - reportNameValuePairs, policy, isEmptyChat = true, isReportReadyForDisplay = true, @@ -98,6 +94,7 @@ function ReportFooter({ } }, }); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const chatFooterStyles = {...styles.chatFooter, minHeight: !isOffline ? CONST.CHAT_FOOTER_MIN_HEIGHT : 0}; const isArchivedRoom = ReportUtils.isArchivedRoom(report, reportNameValuePairs);