From 684d9c83b27640d2988b9aae816d3aafc166c59d Mon Sep 17 00:00:00 2001
From: OSBotify <76178356+OSBotify@users.noreply.github.com>
Date: Mon, 27 Mar 2023 11:57:57 -0400
Subject: [PATCH 1/2] Merge pull request #16565 from
Expensify/version-BUILD-2EBEC063-5C87-4676-A9D4-2ACC8EFFCE69
Update version to 1.2.90-5 on main
(cherry picked from commit 61726eb597720133ac01dd543ce83a8723d293bc)
---
android/app/build.gradle | 4 ++--
ios/NewExpensify/Info.plist | 2 +-
ios/NewExpensifyTests/Info.plist | 2 +-
package-lock.json | 4 ++--
package.json | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/android/app/build.gradle b/android/app/build.gradle
index eebe2c40c3a4..b32820b98a18 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -156,8 +156,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
- versionCode 1001029004
- versionName "1.2.90-4"
+ versionCode 1001029005
+ versionName "1.2.90-5"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
if (isNewArchitectureEnabled()) {
diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist
index cff7e96c5ec0..f4bbbb1eb17d 100644
--- a/ios/NewExpensify/Info.plist
+++ b/ios/NewExpensify/Info.plist
@@ -30,7 +30,7 @@
CFBundleVersion
- 1.2.90.4
+ 1.2.90.5
ITSAppUsesNonExemptEncryption
LSApplicationQueriesSchemes
diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist
index bee389de6da6..7007c90b60fa 100644
--- a/ios/NewExpensifyTests/Info.plist
+++ b/ios/NewExpensifyTests/Info.plist
@@ -19,6 +19,6 @@
CFBundleSignature
????
CFBundleVersion
- 1.2.90.4
+ 1.2.90.5
diff --git a/package-lock.json b/package-lock.json
index d350c6f1bb8e..b160df956411 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "new.expensify",
- "version": "1.2.90-4",
+ "version": "1.2.90-5",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "new.expensify",
- "version": "1.2.90-4",
+ "version": "1.2.90-5",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
diff --git a/package.json b/package.json
index 66c0613cdd3a..8c18c51ff597 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
- "version": "1.2.90-4",
+ "version": "1.2.90-5",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
From 68aa860cb11ba595da5afa3984def1c97998d4e2 Mon Sep 17 00:00:00 2001
From: Rory Abraham <47436092+roryabraham@users.noreply.github.com>
Date: Mon, 27 Mar 2023 15:49:43 +0000
Subject: [PATCH 2/2] Merge pull request #16559 from
Expensify/revert-15942-Rory-FixOfflineMessageCycle
Revert "Make optimistic reportActions appear last"
(cherry picked from commit eb27dbd81147c126c06985b9810beb989891a4c9)
---
src/libs/ReportActionsUtils.js | 20 ++-----------
src/libs/ReportUtils.js | 42 ----------------------------
src/libs/SidebarUtils.js | 12 +++++---
tests/unit/ReportActionsUtilsTest.js | 16 +----------
4 files changed, 11 insertions(+), 79 deletions(-)
diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js
index 7c60e65eda3c..df55ae49faee 100644
--- a/src/libs/ReportActionsUtils.js
+++ b/src/libs/ReportActionsUtils.js
@@ -41,19 +41,8 @@ function isDeletedAction(reportAction) {
}
/**
- * @param {Object} reportAction
- * @returns {Boolean}
- */
-function isOptimisticAction(reportAction) {
- return lodashGet(reportAction, 'pendingAction') === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD;
-}
-
-/**
- * Sort an array of reportActions by:
- *
- * - Finalized actions always are "later" than optimistic actions
- * - then sort by created timestamp
- * - then sort by reportActionID. This gives us a stable order even in the case of multiple reportActions created on the same millisecond
+ * Sort an array of reportActions by their created timestamp first, and reportActionID second
+ * This gives us a stable order even in the case of multiple reportActions created on the same millisecond
*
* @param {Array} reportActions
* @param {Boolean} shouldSortInDescendingOrder
@@ -68,11 +57,6 @@ function getSortedReportActions(reportActions, shouldSortInDescendingOrder = fal
return _.chain(reportActions)
.compact()
.sort((first, second) => {
- // First, make sure that optimistic reportActions appear at the end
- if (isOptimisticAction(second) && !isOptimisticAction(first)) {
- return -1 * invertedMultiplier;
- }
-
// First sort by timestamp
if (first.created !== second.created) {
return (first.created < second.created ? -1 : 1) * invertedMultiplier;
diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js
index e0904aff8ab7..bb07c7d25e34 100644
--- a/src/libs/ReportUtils.js
+++ b/src/libs/ReportUtils.js
@@ -21,7 +21,6 @@ import linkingConfig from './Navigation/linkingConfig';
import * as defaultAvatars from '../components/Icon/DefaultAvatars';
import isReportMessageAttachment from './isReportMessageAttachment';
import * as defaultWorkspaceAvatars from '../components/Icon/WorkspaceDefaultAvatars';
-import * as CollectionUtils from './CollectionUtils';
let sessionEmail;
Onyx.connect({
@@ -72,21 +71,6 @@ Onyx.connect({
callback: val => allReports = val,
});
-const lastReportActions = {};
-Onyx.connect({
- key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
- callback: (actions, key) => {
- if (!key || !actions) {
- return;
- }
- const reportID = CollectionUtils.extractCollectionItemID(key);
- lastReportActions[reportID] = _.find(
- ReportActionsUtils.getSortedReportActionsForDisplay(_.toArray(actions)),
- reportAction => reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
- );
- },
-});
-
let doesDomainHaveApprovedAccountant;
Onyx.connect({
key: ONYXKEYS.ACCOUNT,
@@ -450,31 +434,6 @@ function canShowReportRecipientLocalTime(personalDetails, report) {
&& isReportParticipantValidated);
}
-/**
- * Gets the last message text from the report.
- * Looks at reportActions data as the "best source" for information, because the front-end may have optimistic reportActions that the server is not yet aware of.
- * If reportActions are not loaded for the report, then there can't be any optimistic reportActions, and the lastMessageText rNVP will be accurate as a fallback.
- *
- * @param {Object} report
- * @returns {String}
- */
-function getLastMessageText(report) {
- if (!report) {
- return '';
- }
-
- const lastReportAction = lastReportActions[report.reportID];
- let lastReportActionText = report.lastMessageText;
- let lastReportActionHtml = report.lastMessageHtml;
- if (lastReportAction && lastReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT) {
- lastReportActionText = lodashGet(lastReportAction, 'message[0].text', report.lastMessageText);
- lastReportActionHtml = lodashGet(lastReportAction, 'message[0].html', report.lastMessageHtml);
- }
- return isReportMessageAttachment({text: lastReportActionText, html: lastReportActionHtml})
- ? `[${Localize.translateLocal('common.attachment')}]`
- : Str.htmlDecode(lastReportActionText);
-}
-
/**
* Trim the last message text to a fixed limit.
* @param {String} lastMessageText
@@ -1715,7 +1674,6 @@ export {
isIOUOwnedByCurrentUser,
getIOUTotal,
canShowReportRecipientLocalTime,
- getLastMessageText,
formatReportLastMessageText,
chatIncludesConcierge,
isPolicyExpenseChat,
diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js
index eaa6d3929c5d..3e6fd500c98e 100644
--- a/src/libs/SidebarUtils.js
+++ b/src/libs/SidebarUtils.js
@@ -5,7 +5,6 @@ import lodashOrderBy from 'lodash/orderBy';
import Str from 'expensify-common/lib/str';
import ONYXKEYS from '../ONYXKEYS';
import * as ReportUtils from './ReportUtils';
-import * as ReportActionsUtils from './ReportActionsUtils';
import * as Localize from './Localize';
import CONST from '../CONST';
import * as OptionsListUtils from './OptionsListUtils';
@@ -62,7 +61,7 @@ Onyx.connect({
return;
}
const reportID = CollectionUtils.extractCollectionItemID(key);
- lastReportActions[reportID] = _.first(ReportActionsUtils.getSortedReportActionsForDisplay(_.toArray(actions)));
+ lastReportActions[reportID] = _.last(_.toArray(actions));
reportActions[key] = actions;
},
});
@@ -244,7 +243,12 @@ function getOptionData(reportID) {
// We only create tooltips for the first 10 users or so since some reports have hundreds of users, causing performance to degrade.
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips((participantPersonalDetailList || []).slice(0, 10), hasMultipleParticipants);
- const lastMessageTextFromReport = ReportUtils.getLastMessageText(report);
+ let lastMessageTextFromReport = '';
+ if (ReportUtils.isReportMessageAttachment({text: report.lastMessageText, html: report.lastMessageHtml})) {
+ lastMessageTextFromReport = `[${Localize.translateLocal('common.attachment')}]`;
+ } else {
+ lastMessageTextFromReport = Str.htmlDecode(report ? report.lastMessageText : '');
+ }
// If the last actor's details are not currently saved in Onyx Collection,
// then try to get that from the last report action.
@@ -259,7 +263,7 @@ function getOptionData(reportID) {
let lastMessageText = hasMultipleParticipants && lastActorDetails && (lastActorDetails.login !== currentUserLogin.email)
? `${lastActorDetails.displayName}: `
: '';
- lastMessageText += lastMessageTextFromReport;
+ lastMessageText += report ? lastMessageTextFromReport : '';
if (result.isPolicyExpenseChat && result.isArchivedRoom) {
const archiveReason = (lastReportActions[report.reportID] && lastReportActions[report.reportID].originalMessage && lastReportActions[report.reportID].originalMessage.reason)
diff --git a/tests/unit/ReportActionsUtilsTest.js b/tests/unit/ReportActionsUtilsTest.js
index ad473647dc60..20bf389969b7 100644
--- a/tests/unit/ReportActionsUtilsTest.js
+++ b/tests/unit/ReportActionsUtilsTest.js
@@ -6,15 +6,7 @@ describe('ReportActionsUtils', () => {
const cases = [
[
[
- // This is the lowest created timestamp, but because it's an optimistic action it should appear last
- {
- created: '2022-11-09 20:00:00.000',
- reportActionID: '395268342',
- actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT,
- pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
- },
-
- // This is the highest created timestamp, so should appear 2nd-to-last
+ // This is the highest created timestamp, so should appear last
{
created: '2022-11-09 22:27:01.825',
reportActionID: '8401445780099176',
@@ -69,12 +61,6 @@ describe('ReportActionsUtils', () => {
reportActionID: '8401445780099176',
actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT,
},
- {
- created: '2022-11-09 20:00:00.000',
- reportActionID: '395268342',
- actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT,
- pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
- },
],
],
[