-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix RBR transaction thread is disappearing from the LHN when navigating to another chat v2 #43502
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8137c93
fix RBR transaction thread is disappearing from the LHN when navigati…
tienifr 5438533
fix merge main
tienifr 5f3ce23
fix lint
tienifr 555eecc
fix resolve conflict after merge main
tienifr 76b76d3
fix conflict
tienifr dffc44b
fix remove unused change
tienifr 8ccc4f5
fix display RBR in case oneTransactionReport
tienifr 2308150
fix lint
tienifr 323ce09
fix conflict
tienifr 2965397
fix lint
tienifr b05480c
fix conflict
tienifr cea215f
fix revert fix display RBR in case oneTransactionReport
tienifr fc06e43
fix remove unsed logic
tienifr c9a612c
fix add one line
tienifr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,47 +91,54 @@ function getOrderedReportIDs( | |
const allReportsDictValues = Object.values(allReports ?? {}); | ||
|
||
// Filter out all the reports that shouldn't be displayed | ||
let reportsToDisplay = allReportsDictValues.filter((report) => { | ||
let reportsToDisplay: Array<ChatReportSelector & {hasErrorsOtherThanFailedReceipt?: boolean}> = []; | ||
allReportsDictValues.forEach((report) => { | ||
if (!report) { | ||
return false; | ||
return; | ||
} | ||
|
||
const parentReportActionsKey = `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`; | ||
const parentReportActions = allReportActions?.[parentReportActionsKey]; | ||
const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; | ||
const parentReportAction = parentReportActions?.find((action) => action && action?.reportActionID === report.parentReportActionID); | ||
const doesReportHaveViolations = !!( | ||
betas?.includes(CONST.BETAS.VIOLATIONS) && | ||
!!parentReportAction && | ||
ReportUtils.doesTransactionThreadHaveViolations(report, transactionViolations, parentReportAction as OnyxEntry<ReportAction>) | ||
); | ||
const doesReportHaveViolations = OptionsListUtils.shouldShowViolations(report, betas ?? [], transactionViolations); | ||
const isHidden = report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; | ||
const isFocused = report.reportID === currentReportId; | ||
const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}; | ||
const hasErrorsOtherThanFailedReceipt = | ||
doesReportHaveViolations || Object.values(allReportErrors).some((error) => error?.[0] !== Localize.translateLocal('iou.error.genericSmartscanFailureMessage')); | ||
if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID ?? '0')) { | ||
return; | ||
} | ||
if (hasErrorsOtherThanFailedReceipt) { | ||
reportsToDisplay.push({ | ||
...report, | ||
hasErrorsOtherThanFailedReceipt: true, | ||
}); | ||
return; | ||
} | ||
const isSystemChat = ReportUtils.isSystemChat(report); | ||
const shouldOverrideHidden = hasErrorsOtherThanFailedReceipt || isFocused || isSystemChat || report.isPinned; | ||
if (isHidden && !shouldOverrideHidden) { | ||
return false; | ||
return; | ||
} | ||
|
||
const participantAccountIDs = Object.keys(report?.participants ?? {}).map(Number); | ||
|
||
if (currentUserAccountID && AccountUtils.isAccountIDOddNumber(currentUserAccountID) && participantAccountIDs.includes(CONST.ACCOUNT_ID.NOTIFICATIONS)) { | ||
return true; | ||
reportsToDisplay.push(report); | ||
return; | ||
} | ||
if ( | ||
ReportUtils.shouldReportBeInOptionList({ | ||
report, | ||
currentReportId: currentReportId ?? '-1', | ||
isInFocusMode, | ||
betas, | ||
policies: policies as OnyxCollection<Policy>, | ||
excludeEmptyChats: true, | ||
doesReportHaveViolations, | ||
includeSelfDM: true, | ||
}) | ||
) { | ||
reportsToDisplay.push(report); | ||
} | ||
|
||
return ReportUtils.shouldReportBeInOptionList({ | ||
report, | ||
currentReportId: currentReportId ?? '-1', | ||
isInFocusMode, | ||
betas, | ||
policies: policies as OnyxCollection<Policy>, | ||
excludeEmptyChats: true, | ||
doesReportHaveViolations, | ||
includeSelfDM: true, | ||
}); | ||
}); | ||
|
||
// The LHN is split into four distinct groups, and each group is sorted a little differently. The groups will ALWAYS be in this order: | ||
|
@@ -143,10 +150,12 @@ function getOrderedReportIDs( | |
// 4. Archived reports | ||
// - Sorted by lastVisibleActionCreated in default (most recent) view mode | ||
// - Sorted by reportDisplayName in GSD (focus) view mode | ||
|
||
const pinnedAndGBRReports: MiniReport[] = []; | ||
const draftReports: MiniReport[] = []; | ||
const nonArchivedReports: MiniReport[] = []; | ||
const archivedReports: MiniReport[] = []; | ||
const errorReports: MiniReport[] = []; | ||
|
||
if (currentPolicyID || policyMemberAccountIDs.length > 0) { | ||
reportsToDisplay = reportsToDisplay.filter( | ||
|
@@ -155,7 +164,7 @@ function getOrderedReportIDs( | |
} | ||
// There are a few properties that need to be calculated for the report which are used when sorting reports. | ||
reportsToDisplay.forEach((reportToDisplay) => { | ||
const report = reportToDisplay as OnyxEntry<Report>; | ||
const report = reportToDisplay; | ||
const miniReport: MiniReport = { | ||
reportID: report?.reportID, | ||
displayName: ReportUtils.getReportName(report), | ||
|
@@ -170,13 +179,16 @@ function getOrderedReportIDs( | |
draftReports.push(miniReport); | ||
} else if (ReportUtils.isArchivedRoom(report)) { | ||
archivedReports.push(miniReport); | ||
} else if (report?.hasErrorsOtherThanFailedReceipt) { | ||
errorReports.push(miniReport); | ||
} else { | ||
nonArchivedReports.push(miniReport); | ||
} | ||
}); | ||
|
||
// Sort each group of reports accordingly | ||
pinnedAndGBRReports.sort((a, b) => (a?.displayName && b?.displayName ? localeCompare(a.displayName, b.displayName) : 0)); | ||
errorReports.sort((a, b) => (a?.displayName && b?.displayName ? localeCompare(a.displayName, b.displayName) : 0)); | ||
draftReports.sort((a, b) => (a?.displayName && b?.displayName ? localeCompare(a.displayName, b.displayName) : 0)); | ||
|
||
if (isInDefaultMode) { | ||
|
@@ -197,7 +209,9 @@ function getOrderedReportIDs( | |
|
||
// Now that we have all the reports grouped and sorted, they must be flattened into an array and only return the reportID. | ||
// The order the arrays are concatenated in matters and will determine the order that the groups are displayed in the sidebar. | ||
const LHNReports = [...pinnedAndGBRReports, ...draftReports, ...nonArchivedReports, ...archivedReports].map((report) => report?.reportID ?? '-1'); | ||
|
||
const LHNReports = [...pinnedAndGBRReports, ...errorReports, ...draftReports, ...nonArchivedReports, ...archivedReports].map((report) => report?.reportID ?? '-1'); | ||
|
||
return LHNReports; | ||
} | ||
|
||
|
@@ -276,7 +290,15 @@ function getOptionData({ | |
result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); | ||
result.shouldShowSubscript = ReportUtils.shouldReportShowSubscript(report); | ||
result.pendingAction = report.pendingFields?.addWorkspaceRoom ?? report.pendingFields?.createChat; | ||
|
||
result.brickRoadIndicator = hasErrors || hasViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; | ||
const oneTransactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, reportActions); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could do with an explanatory comment here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
const isOneTransactionReport = oneTransactionThreadReportID !== null; | ||
if (isOneTransactionReport) { | ||
const allTransactionErrors = OptionsListUtils.getAllReportErrors(report, reportActions); | ||
const hasTransactionErrors = Object.keys(allTransactionErrors ?? {}).length !== 0; | ||
result.brickRoadIndicator = hasTransactionErrors || hasViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; | ||
} | ||
result.ownerAccountID = report.ownerAccountID; | ||
result.managerID = report.managerID; | ||
result.reportID = report.reportID; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment here would be nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tienifr Bump on this 🙏