From db66aeee82f188564c3ec0e9087a3dff9dd24d9a Mon Sep 17 00:00:00 2001 From: Vivek Kumar Date: Fri, 22 Sep 2023 15:52:31 +0530 Subject: [PATCH 1/2] added conditional navigation for the private notes --- src/libs/ReportUtils.js | 19 +++++++++++++++++++ src/pages/ProfilePage.js | 2 +- src/pages/ReportDetailsPage.js | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index edf646d0266b..f867e5b9ea3b 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -3561,6 +3561,24 @@ function getReportPreviewDisplayTransactions(reportPreviewAction) { ); } +/** + * Navigates a user to either privateNotesListPage if there are multiple notes accessible by the user on the report or to the privateNotesViewPage if there is just a single note + * @param {*} report + * @param {*} accountID + */ +function navigateToPrivateNotesPage(report, accountID = currentUserAccountID) { + if (!report) { + return; + } + + // Get all the private notes on the report + const privateNotes = lodashGet(report, 'privateNotes', {}); + + if (_.keys(privateNotes) === 1) { + Navigation.navigate(ROUTES.getPrivateNotesViewRoute(report.reportID, accountID)); + } + Navigation.navigate(Routes.getPrivateNotesListRoute(report.reportID)); +} export { getReportParticipantsTitle, isReportMessageAttachment, @@ -3701,4 +3719,5 @@ export { getReportPreviewDisplayTransactions, getTransactionsWithReceipts, hasMissingSmartscanFields, + navigateToPrivateNotesPage, }; diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index b515da04b7be..084998ddd8cc 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -243,7 +243,7 @@ function ProfilePage(props) { title={`${props.translate('privateNotes.title')}`} titleStyle={styles.flex1} icon={Expensicons.Pencil} - onPress={() => Navigation.navigate(ROUTES.getPrivateNotesListRoute(chatReportWithCurrentUser.reportID))} + onPress={() => ReportUtils.navigateToPrivateNotesPage(chatReportWithCurrentUser)} wrapperStyle={styles.breakAll} shouldShowRightIcon brickRoadIndicator={Report.hasErrorInPrivateNotes(chatReportWithCurrentUser) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index 3a9e0f5c2eb8..940903e0812a 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -119,7 +119,7 @@ function ReportDetailsPage(props) { translationKey: 'privateNotes.title', icon: Expensicons.Pencil, isAnonymousAction: false, - action: () => Navigation.navigate(ROUTES.getPrivateNotesListRoute(props.report.reportID)), + action: () => ReportUtils.navigateToPrivateNotesPage(reportID), brickRoadIndicator: Report.hasErrorInPrivateNotes(props.report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '', }); } From c5f1d9202c9e41a839de25f06be08e74b785bec3 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Date: Fri, 22 Sep 2023 15:54:11 +0530 Subject: [PATCH 2/2] updated the style for the private notes composer --- src/libs/ReportUtils.js | 6 +++--- src/pages/PrivateNotes/PrivateNotesEditPage.js | 2 +- src/pages/ReportDetailsPage.js | 2 +- src/styles/styles.js | 4 ++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index f867e5b9ea3b..a710425be147 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -3563,8 +3563,8 @@ function getReportPreviewDisplayTransactions(reportPreviewAction) { /** * Navigates a user to either privateNotesListPage if there are multiple notes accessible by the user on the report or to the privateNotesViewPage if there is just a single note - * @param {*} report - * @param {*} accountID + * @param {*} report + * @param {*} accountID */ function navigateToPrivateNotesPage(report, accountID = currentUserAccountID) { if (!report) { @@ -3577,7 +3577,7 @@ function navigateToPrivateNotesPage(report, accountID = currentUserAccountID) { if (_.keys(privateNotes) === 1) { Navigation.navigate(ROUTES.getPrivateNotesViewRoute(report.reportID, accountID)); } - Navigation.navigate(Routes.getPrivateNotesListRoute(report.reportID)); + Navigation.navigate(ROUTES.getPrivateNotesListRoute(report.reportID)); } export { getReportParticipantsTitle, diff --git a/src/pages/PrivateNotes/PrivateNotesEditPage.js b/src/pages/PrivateNotes/PrivateNotesEditPage.js index 206e9e74d91f..60e8cbb6bc8a 100644 --- a/src/pages/PrivateNotes/PrivateNotesEditPage.js +++ b/src/pages/PrivateNotes/PrivateNotesEditPage.js @@ -123,7 +123,7 @@ function PrivateNotesEditPage({route, personalDetailsList, session, report}) { autoCorrect={false} autoGrowHeight textAlignVertical="top" - containerStyles={[styles.autoGrowHeightMultilineInput]} + containerStyles={[styles.privateNotesMultilineInput]} defaultValue={privateNote} value={privateNote} onChangeText={(text) => setPrivateNote(text)} diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index 940903e0812a..348fc5e6ec51 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -119,7 +119,7 @@ function ReportDetailsPage(props) { translationKey: 'privateNotes.title', icon: Expensicons.Pencil, isAnonymousAction: false, - action: () => ReportUtils.navigateToPrivateNotesPage(reportID), + action: () => ReportUtils.navigateToPrivateNotesPage(props.report), brickRoadIndicator: Report.hasErrorInPrivateNotes(props.report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '', }); } diff --git a/src/styles/styles.js b/src/styles/styles.js index 4a2472913fd2..637ab1430812 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -2992,6 +2992,10 @@ const styles = (theme) => ({ maxHeight: 115, }, + privateNotesMultilineInput: { + maxHeight: 225, + }, + peopleRow: { width: '100%', flexDirection: 'row',