Skip to content

Commit

Permalink
Merge pull request #19246 from Expensify/OSBotify-cherry-pick-staging…
Browse files Browse the repository at this point in the history
…-19219

🍒 Cherry pick PR #19219 to staging 🍒
  • Loading branch information
OSBotify authored May 19, 2023
2 parents 3e7e15e + d18c441 commit e706f91
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001031603
versionName "1.3.16-3"
versionCode 1001031604
versionName "1.3.16-4"
}

splits {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.3.16.3</string>
<string>1.3.16.4</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.3.16.3</string>
<string>1.3.16.4</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.3.16-3",
"version": "1.3.16-4",
"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.",
Expand Down Expand Up @@ -220,6 +220,17 @@
"overrides": {
"react-native": "$react-native"
},
"electronmon": {
"patterns": [
"!node_modules",
"!node_modules/**/*",
"!**/*.map",
"!ios/**",
"!android/**",
"*.test.*",
"*.spec.*"
]
},
"engines": {
"node": "16.15.1",
"npm": "8.11.0"
Expand Down
34 changes: 11 additions & 23 deletions src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,15 @@ import * as LocalePhoneNumber from './LocalePhoneNumber';
// Note: It is very important that the keys subscribed to here are the same
// keys that are connected to SidebarLinks withOnyx(). If there was a key missing from SidebarLinks and it's data was updated
// for that key, then there would be no re-render and the options wouldn't reflect the new data because SidebarUtils.getOrderedReportIDs() wouldn't be triggered.
// There are a couple of keys here which are OK to have stale data. iouReports for example, doesn't need to exist in withOnyx() because
// when IOUs change, it also triggers a change on the reports collection. Having redundant subscriptions causes more re-renders which should be avoided.
// There are a couple of keys here which are OK to have stale data. Having redundant subscriptions causes more re-renders which should be avoided.
// Session also can remain stale because the only way for the current user to change is to sign out and sign in, which would clear out all the Onyx
// data anyway and cause SidebarLinks to rerender.

const chatReports = {};
const moneyRequestReports = {};
let allReports;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
callback: (report, key) => {
if (!report) {
delete moneyRequestReports[key];
delete chatReports[key];
} else if (ReportUtils.isMoneyRequestReport(report)) {
moneyRequestReports[key] = report;
} else {
chatReports[key] = report;
}
},
waitForCollectionCallback: true,
callback: (val) => (allReports = val),
});

let personalDetails;
Expand Down Expand Up @@ -108,9 +98,7 @@ function getOrderedReportIDs(reportIDFromRoute) {
const isInDefaultMode = !isInGSDMode;

// Filter out all the reports that shouldn't be displayed
const reportsToDisplay = _.filter({...chatReports, ...moneyRequestReports}, (report) =>
ReportUtils.shouldReportBeInOptionList(report, reportIDFromRoute, isInGSDMode, currentUserLogin, moneyRequestReports, betas, policies),
);
const reportsToDisplay = _.filter(allReports, (report) => ReportUtils.shouldReportBeInOptionList(report, reportIDFromRoute, isInGSDMode, currentUserLogin, allReports, betas, policies));

// There are a few properties that need to be calculated for the report which are used when sorting reports.
_.each(reportsToDisplay, (report) => {
Expand All @@ -121,7 +109,7 @@ function getOrderedReportIDs(reportIDFromRoute) {
report.displayName = ReportUtils.getReportName(report);

// eslint-disable-next-line no-param-reassign
report.iouReportAmount = ReportUtils.getMoneyRequestTotal(report, moneyRequestReports);
report.iouReportAmount = ReportUtils.getMoneyRequestTotal(report, allReports);
});

// The LHN is split into five distinct groups, and each group is sorted a little differently. The groups will ALWAYS be in this order:
Expand All @@ -146,7 +134,7 @@ function getOrderedReportIDs(reportIDFromRoute) {
return;
}

if (report.hasOutstandingIOU && !ReportUtils.isIOUOwnedByCurrentUser(report, moneyRequestReports)) {
if (report.hasOutstandingIOU && !ReportUtils.isIOUOwnedByCurrentUser(report, allReports)) {
outstandingIOUReports.push(report);
return;
}
Expand Down Expand Up @@ -196,7 +184,7 @@ function getOrderedReportIDs(reportIDFromRoute) {
*/
function getOptionData(reportID) {
const reportKey = `${ONYXKEYS.COLLECTION.REPORT}${reportID}`;
const report = chatReports[reportKey] || moneyRequestReports[reportKey];
const report = allReports[reportKey];

// When a user signs out, Onyx is cleared. Due to the lazy rendering with a virtual list, it's possible for
// this method to be called after the Onyx data has been cleared out. In that case, it's fine to do
Expand Down Expand Up @@ -260,7 +248,7 @@ function getOptionData(reportID) {
result.tooltipText = ReportUtils.getReportParticipantsTitle(report.participants || []);
result.hasOutstandingIOU = report.hasOutstandingIOU;
result.parentReportID = report.parentReportID || null;
const parentReport = result.parentReportID ? chatReports[`${ONYXKEYS.COLLECTION.REPORT}${result.parentReportID}`] : null;
const parentReport = result.parentReportID ? allReports[`${ONYXKEYS.COLLECTION.REPORT}${result.parentReportID}`] : null;
const hasMultipleParticipants = participantPersonalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat;
const subtitle = ReportUtils.getChatRoomSubtitle(report);

Expand Down Expand Up @@ -329,8 +317,8 @@ function getOptionData(reportID) {
result.alternateText = lastMessageText || formattedLogin;
}

result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result, moneyRequestReports);
result.iouReportAmount = ReportUtils.getMoneyRequestTotal(result, moneyRequestReports);
result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result, allReports);
result.iouReportAmount = ReportUtils.getMoneyRequestTotal(result, allReports);

if (!hasMultipleParticipants) {
result.login = personalDetail.login;
Expand Down

0 comments on commit e706f91

Please sign in to comment.