From f654c20ff9f5bfe44670105f1b52dddd91f07c7c Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 6 May 2021 06:24:53 -1000 Subject: [PATCH 1/3] Fix some propTypes errors --- src/libs/Navigation/AppNavigator/MainDrawerNavigator.js | 2 +- src/pages/home/sidebar/OptionRow.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js b/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js index f53b61989864..344eff33261f 100644 --- a/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js +++ b/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js @@ -41,7 +41,7 @@ const getInitialReportScreenParams = _.once((reports) => { // Fallback to empty if for some reason reportID cannot be derived - prevents the app from crashing const reportID = lodashGet(last, 'reportID', ''); - return {reportID}; + return {reportID: String(reportID)}; }); const MainDrawerNavigator = (props) => { diff --git a/src/pages/home/sidebar/OptionRow.js b/src/pages/home/sidebar/OptionRow.js index 87954e6c48e3..0802b4ef529b 100644 --- a/src/pages/home/sidebar/OptionRow.js +++ b/src/pages/home/sidebar/OptionRow.js @@ -194,7 +194,7 @@ const OptionRow = ({ {option.hasDraftComment && ( - + )} {option.hasOutstandingIOU && ( @@ -202,7 +202,7 @@ const OptionRow = ({ )} {option.isPinned && ( - + )} From 2c2ffa053c0b699f8d2f18aa647fa2b6bbdfc0cc Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 6 May 2021 09:16:44 -1000 Subject: [PATCH 2/3] only use maxSequenceNumber if it is defined --- src/libs/actions/Report.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 8f2f712e89dc..f3a59fbe8ba9 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -940,9 +940,16 @@ function addAction(reportID, text, file) { * is last read (meaning that the entire report history has been read) */ function updateLastReadActionID(reportID, sequenceNumber) { + // If we don't have a maxSequenceNumber for this report then we will assume that the report has just been created + // and use 0 for the maxSequenceNumber. Otherwise, we'll have an undefined sequenceNumber in cases where no + // sequenceNumber is explicitly passed. + const maxSequenceNumber = !_.isUndefined(reportMaxSequenceNumbers[reportID]) + ? reportMaxSequenceNumbers[reportID] + : 0; + // Need to subtract 1 from sequenceNumber so that the "New" marker appears in the right spot (the last read // action). If 1 isn't subtracted then the "New" marker appears one row below the action (the first unread action) - const lastReadSequenceNumber = (sequenceNumber - 1) || reportMaxSequenceNumbers[reportID]; + const lastReadSequenceNumber = (sequenceNumber - 1) || maxSequenceNumber; setLocalLastRead(reportID, lastReadSequenceNumber); From 651801ab68af6cf7ac16b13dd77873fca2cab516 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 6 May 2021 12:17:53 -1000 Subject: [PATCH 3/3] return early and fix comment --- src/libs/actions/Report.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index f3a59fbe8ba9..253e8e39a9ee 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -940,16 +940,16 @@ function addAction(reportID, text, file) { * is last read (meaning that the entire report history has been read) */ function updateLastReadActionID(reportID, sequenceNumber) { - // If we don't have a maxSequenceNumber for this report then we will assume that the report has just been created - // and use 0 for the maxSequenceNumber. Otherwise, we'll have an undefined sequenceNumber in cases where no - // sequenceNumber is explicitly passed. - const maxSequenceNumber = !_.isUndefined(reportMaxSequenceNumbers[reportID]) - ? reportMaxSequenceNumbers[reportID] - : 0; + // If we aren't specifying a sequenceNumber and have no maxSequenceNumber for this report then we should not update + // the last read. Most likely, we have just created the report and it has no comments. But we should err on the side + // of caution and do nothing in this case. + if (_.isUndefined(sequenceNumber) && _.isUndefined(reportMaxSequenceNumbers[reportID])) { + return; + } // Need to subtract 1 from sequenceNumber so that the "New" marker appears in the right spot (the last read // action). If 1 isn't subtracted then the "New" marker appears one row below the action (the first unread action) - const lastReadSequenceNumber = (sequenceNumber - 1) || maxSequenceNumber; + const lastReadSequenceNumber = (sequenceNumber - 1) || reportMaxSequenceNumbers[reportID]; setLocalLastRead(reportID, lastReadSequenceNumber);