Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5050,6 +5050,7 @@ const CONST = {
INFO: 'info',
},
REPORT_DETAILS_MENU_ITEM: {
GO_TO_ROOM: 'goToRoom',
MEMBERS: 'member',
INVITE: 'invite',
SETTINGS: 'settings',
Expand Down
11 changes: 10 additions & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,16 @@ const DYNAMIC_ROUTES = {
},
REPORT_DETAILS: {
path: 'details',
entryScreens: [SCREENS.RIGHT_MODAL.SEARCH_REPORT, SCREENS.RIGHT_MODAL.EXPENSE_REPORT, SCREENS.REPORT, SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT, SCREENS.SEARCH.ROOT],
entryScreens: [
SCREENS.RIGHT_MODAL.SEARCH_REPORT,
SCREENS.RIGHT_MODAL.EXPENSE_REPORT,
SCREENS.REPORT,
SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT,
SCREENS.SEARCH.ROOT,
SCREENS.WORKSPACE.ROOMS,
],
getRoute: (reportID: string) => getUrlWithParams('details', {reportID}),
queryParams: ['reportID'],
},
REPORT_DETAILS_SHARE_CODE: {
path: 'share-code',
Expand Down
9 changes: 8 additions & 1 deletion src/components/Tables/WorkspaceRoomsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {ListRenderItemInfo} from '@shopify/flash-list';
import React, {useEffect, useRef} from 'react';
import type {CompareItemsCallback, IsItemInSearchCallback, TableColumn, TableHandle} from '@components/Table';
import Table from '@components/Table';
import useBottomSafeSafeAreaPaddingStyle from '@hooks/useBottomSafeSafeAreaPaddingStyle';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -26,6 +27,12 @@ function WorkspaceRoomsTable({rooms, highlightedReportID}: WorkspaceRoomsTablePr
const shouldUseNarrowTableLayout = shouldUseNarrowLayout || isMediumScreenWidth;
const tableRef = useRef<TableHandle<WorkspaceRoomRowData, WorkspaceRoomsTableColumnKey>>(null);

const tableBodyContentContainerStyle = useBottomSafeSafeAreaPaddingStyle({
addBottomSafeAreaPadding: true,
addOfflineIndicatorBottomSafeAreaPadding: true,
style: styles.pb5,
});

useEffect(() => {
if (!highlightedReportID) {
return;
Expand Down Expand Up @@ -83,7 +90,7 @@ function WorkspaceRoomsTable({rooms, highlightedReportID}: WorkspaceRoomsTablePr
>
<Table.SearchBar label={translate('workspace.common.findRoom')} />
<Table.Header />
<Table.Body />
<Table.Body contentContainerStyle={tableBodyContentContainerStyle} />
</Table>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2904,6 +2904,7 @@ ${amount} für ${merchant} – ${date}`,
waitForPDF: 'Bitte warten, während wir das PDF erstellen.',
errorPDF: 'Beim Versuch, Ihre PDF zu erstellen, ist ein Fehler aufgetreten',
successPDF: 'Dein PDF wurde erstellt! Falls es nicht automatisch heruntergeladen wurde, verwende die Schaltfläche unten.',
goToRoom: 'Zum Raum gehen',
},
reportDescriptionPage: {
roomDescription: 'Zimmerbeschreibung',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2976,6 +2976,7 @@ const translations = {
},
},
reportDetailsPage: {
goToRoom: 'Go to room',
inWorkspace: (policyName: string) => `in ${policyName}`,
generatingPDF: 'Generate PDF',
waitForPDF: 'Please wait while we generate the PDF.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2774,6 +2774,7 @@ ${amount} para ${merchant} - ${date}`,
},
},
reportDetailsPage: {
goToRoom: 'Ir a la sala',
inWorkspace: (policyName) => `en ${policyName}`,
generatingPDF: 'Generar PDF',
waitForPDF: 'Por favor, espera mientras creamos el PDF.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2912,6 +2912,7 @@ ${amount} pour ${merchant} - ${date}`,
waitForPDF: 'Veuillez patienter pendant que nous générons le PDF.',
errorPDF: 'Une erreur s’est produite lors de la tentative de génération de votre PDF',
successPDF: 'Votre PDF a été généré ! S’il ne s’est pas téléchargé automatiquement, utilisez le bouton ci-dessous.',
goToRoom: 'Aller à la salle',
},
reportDescriptionPage: {
roomDescription: 'Description de la salle',
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2900,6 +2900,7 @@ ${amount} per ${merchant} - ${date}`,
waitForPDF: 'Attendi mentre generiamo il PDF.',
errorPDF: 'Si è verificato un errore durante il tentativo di generare il tuo PDF',
successPDF: 'Il tuo PDF è stato generato! Se non è stato scaricato automaticamente, usa il pulsante qui sotto.',
goToRoom: 'Vai alla stanza',
},
reportDescriptionPage: {
roomDescription: 'Descrizione stanza',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2872,6 +2872,7 @@ ${date} の ${merchant} への ${amount}`,
waitForPDF: 'PDF を作成しています。しばらくお待ちください。',
errorPDF: 'PDF の生成中にエラーが発生しました',
successPDF: 'PDFが作成されました!自動的にダウンロードされない場合は、下のボタンを使用してください。',
goToRoom: 'ルームに移動',
},
reportDescriptionPage: {
roomDescription: '部屋の説明',
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2897,6 +2897,7 @@ ${amount} voor ${merchant} - ${date}`,
waitForPDF: 'Even geduld terwijl we de pdf genereren.',
errorPDF: 'Er is een fout opgetreden bij het genereren van je PDF',
successPDF: 'Je PDF is gegenereerd! Als het niet automatisch is gedownload, gebruik dan de knop hieronder.',
goToRoom: 'Ga naar kamer',
},
reportDescriptionPage: {
roomDescription: 'Kamerbeschrijving',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2891,6 +2891,7 @@ ${amount} dla ${merchant} - ${date}`,
waitForPDF: 'Poczekaj, aż wygenerujemy plik PDF.',
errorPDF: 'Wystąpił błąd podczas próby wygenerowania Twojego pliku PDF',
successPDF: 'Twój plik PDF został wygenerowany! Jeśli nie pobrał się automatycznie, użyj przycisku poniżej.',
goToRoom: 'Przejdź do pokoju',
},
reportDescriptionPage: {
roomDescription: 'Opis pokoju',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2891,6 +2891,7 @@ ${amount} para ${merchant} - ${date}`,
waitForPDF: 'Aguarde enquanto geramos o PDF.',
errorPDF: 'Ocorreu um erro ao tentar gerar seu PDF',
successPDF: 'Seu PDF foi gerado! Se ele não foi baixado automaticamente, use o botão abaixo.',
goToRoom: 'Ir para a sala',
},
reportDescriptionPage: {
roomDescription: 'Descrição do quarto',
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2815,6 +2815,7 @@ ${amount},商户:${merchant} - 日期:${date}`,
waitForPDF: '正在生成 PDF,请稍候。',
errorPDF: '尝试生成您的 PDF 时出错',
successPDF: '您的 PDF 已生成!如果没有自动下载,请使用下面的按钮。',
goToRoom: '进入房间',
},
reportDescriptionPage: {
roomDescription: '房间描述',
Expand Down
23 changes: 22 additions & 1 deletion src/pages/DynamicReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import getBase62ReportID from '@libs/getBase62ReportID';
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import isReportTopmostSplitNavigator from '@libs/Navigation/helpers/isReportTopmostSplitNavigator';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {ReportDetailsNavigatorParamList, RightModalNavigatorParamList} from '@libs/Navigation/types';
Expand Down Expand Up @@ -179,6 +180,7 @@ function DynamicReportDetailsPage({policy, report, route, reportMetadata, report
'Camera',
'Trashcan',
'ArrowSplit',
'Hashtag',
]);
const navigateBackFromReportDetailsPath = useDynamicBackPath(DYNAMIC_ROUTES.REPORT_DETAILS.path);

Expand Down Expand Up @@ -379,7 +381,11 @@ function DynamicReportDetailsPage({policy, report, route, reportMetadata, report
}, [showConfirmModal, translate, leaveChat]);

const shouldShowLeaveButton = canLeaveChat(report, policy, currentUserPersonalDetails?.accountID, !!reportNameValuePairs?.private_isArchived);
const shouldShowGoToWorkspace = shouldShowPolicy(policy, false, currentUserPersonalDetails?.email) && !policy?.isJoinRequestPending;

// Only show the "Go to room" row when the Details page was opened from a screen other than the room report itself (e.g. the Workspace rooms list).
const isRoomCurrentlyOpen = isReportTopmostSplitNavigator() && Navigation.getTopmostReportId() === report?.reportID;
const shouldShowGoToRoom = (isChatRoom || isPolicyExpenseChat) && !isRoomCurrentlyOpen;
const shouldShowGoToWorkspace = shouldShowPolicy(policy, false, currentUserPersonalDetails?.email) && !policy?.isJoinRequestPending && !shouldShowGoToRoom;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from #93257

isRoomCurrentlyOpen reads live navigation state during render. When "Go to room" is tapped, getTopmostReportId() updates before the RHP closes, so the row flips to "Go to workspace" briefly.

Fixed in #93296 by snapshotting this on focus instead of reading it reactively during the transition.


const reportForHeader = useMemo(() => getReportForHeader(report), [report]);
const shouldParseFullTitle = parentReportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT && !isGroupChat;
Expand Down Expand Up @@ -411,6 +417,19 @@ function DynamicReportDetailsPage({policy, report, route, reportMetadata, report
return items;
}

if (shouldShowGoToRoom) {
items.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.GO_TO_ROOM,
translationKey: 'reportDetailsPage.goToRoom',
icon: expensifyIcons.Hashtag,
isAnonymousAction: false,
shouldShowRightIcon: true,
action: () => {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report?.reportID));
},
});
}

// The Members page is only shown when:
// - The report is a thread in a chat report
// - The report is not a user created room with participants to show i.e. DM, Group Chat, etc
Expand Down Expand Up @@ -630,6 +649,7 @@ function DynamicReportDetailsPage({policy, report, route, reportMetadata, report
}, [
isSelfDM,
isArchivedRoom,
shouldShowGoToRoom,
isGroupChat,
isDefaultRoom,
isChatThread,
Expand Down Expand Up @@ -660,6 +680,7 @@ function DynamicReportDetailsPage({policy, report, route, reportMetadata, report
expensifyIcons.Building,
expensifyIcons.Exit,
expensifyIcons.Bug,
expensifyIcons.Hashtag,
styles.ph2,
shouldOpenRoomMembersPage,
navigateBackFromReportDetailsPath,
Expand Down
10 changes: 8 additions & 2 deletions src/pages/workspace/rooms/WorkspaceRoomsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import useWorkspaceDocumentTitle from '@hooks/useWorkspaceDocumentTitle';
import {openPolicyRoomsPage} from '@libs/actions/Policy/Room';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import {getDisplayNameOrDefault} from '@libs/PersonalDetailsUtils';
import {isPolicyAdmin} from '@libs/PolicyUtils';
import {getReportName} from '@libs/ReportNameUtils';
import {getParticipantsAccountIDsForDisplay} from '@libs/ReportUtils';
import type {WorkspaceSplitNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';

type WorkspaceRoomsPageProps = PlatformStackScreenProps<WorkspaceSplitNavigatorParamList, typeof SCREENS.WORKSPACE.ROOMS>;
Expand All @@ -42,6 +44,7 @@ function WorkspaceRoomsPage({route}: WorkspaceRoomsPageProps) {
const illustrations = useMemoizedLazyIllustrations(['Hashtag']);
const policyID = route.params.policyID;
const policy = usePolicy(policyID);
const isAdmin = isPolicyAdmin(policy);
useWorkspaceDocumentTitle(policy?.name, 'workspace.common.rooms');

const reportAttributes = useReportAttributes();
Expand Down Expand Up @@ -70,7 +73,10 @@ function WorkspaceRoomsPage({route}: WorkspaceRoomsPageProps) {
ownerAvatar: ownerDetails?.avatar,
ownerDisplayName: ownerDetails ? getDisplayNameOrDefault(ownerDetails) : '',
memberCount: getParticipantsAccountIDsForDisplay(report, true, false, false, undefined, personalDetails).length,
action: () => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID)),
action: () => {
const targetRoute = isAdmin ? createDynamicRoute(DYNAMIC_ROUTES.REPORT_DETAILS.getRoute(report.reportID)) : ROUTES.REPORT_WITH_ID.getRoute(report.reportID);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid deriving the details route from the active RHP

When an admin has one room details panel open on the workspace Rooms page and selects another visible room row without closing it, createDynamicRoute() defaults to Navigation.getActiveRoute(), which is already the dynamic details URL containing ?reportID=<old>. The new suffix from DYNAMIC_ROUTES.REPORT_DETAILS.getRoute(report.reportID) also contains reportID, so the dynamic-route helper throws on the duplicate query key instead of opening the second room. Build this from the stable rooms base route (or close/replace the current RHP) rather than the current active route.

Useful? React with 👍 / 👎.

Navigation.navigate(targetRoute);
},
};
});

Expand Down
Loading