-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
HIGH: [Polish] [$500] Finalize order of LHN in #focus mode #33029
Comments
Upgrading to HIGH as it's fundamentally about making it work correctly. |
Job added to Upwork: https://www.upwork.com/jobs/~01432274cc2b58438c |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @fedirjh ( |
Triggered auto assignment to @JmillsExpensify ( |
Bug0 Triage Checklist (Main S/O)
|
ProposalPlease re-state the problem that we are trying to solve in this issueFinalize order of LHN in #focus mode What is the root cause of that problem?This should be fixed with What changes do you think we should make in order to solve the problem?We should modify the
result.allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) as OnyxCommon.Errors;
result.brickRoadIndicator = Object.keys(result.allReportErrors ?? {}).length !== 0 ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; These lines of code was used to determine the RBR indicator in We need to use this inside
For this we need to use the replace Only caveat right now is that after replace string can get empty, and in js, this will get highest preference in sorting order. @quinthar I need your opinion on this: should we push these reports down by temporarily replacing empty string with Edit: The What alternative solutions did you explore? (Optional) |
LHN Sorting Logic ProposalProblem StatementWhen the LHN (Left Hand Navigation) is in "focus" mode, the existing sorting logic was not aligning with the expected behavior. The sorting criteria were not correctly implemented, specifically for pinned reports and those in "focus" mode. SolutionThe LHN sorting logic has been reviewed and updated to meet the following requirements: Sorting Criteria
Additional Considerations
Implementation DetailsSorting FunctionThe existing sorting function has been modified to achieve the desired behavior. Here are the key updates:
UsageThe const sortedLHNReports = sortLHNReports(reportsToDisplay, isInDefaultMode);
// Function to sort LHN reports
function sortLHNReports(reportsToDisplay: Report[], isInDefaultMode: boolean): string[] {
const pinnedAndGBRReports: Report[] = [];
const draftReports: Report[] = [];
const nonArchivedReports: Report[] = [];
const archivedReports: Report[] = [];
// Calculate properties and categorize reports
reportsToDisplay.forEach((report) => {
report.displayName = ReportUtils.getReportName(report);
report.iouReportAmount = ReportUtils.getMoneyRequestReimbursableTotal(report, allReports);
const isPinned = report.isPinned ?? false;
const reportAction = ReportActionsUtils.getReportAction(report.parentReportID ?? '', report.parentReportActionID ?? '');
if (isPinned || ReportUtils.requiresAttentionFromCurrentUser(report, reportAction)) {
pinnedAndGBRReports.push(report);
} else if (report.hasDraft) {
draftReports.push(report);
} else if (ReportUtils.isArchivedRoom(report)) {
archivedReports.push(report);
} else {
nonArchivedReports.push(report);
}
});
// Sort each group of reports accordingly
pinnedAndGBRReports.sort((a, b) => (a.displayName && b.displayName ? a.displayName.localeCompare(b.displayName) : 0));
draftReports.sort((a, b) => (a.displayName && b.displayName ? a.displayName.localeCompare(b.displayName) : 0));
if (isInDefaultMode) {
// Sort non-archived reports based on most recent activity and alphabetically
nonArchivedReports.sort((a, b) => {
const compareDates = a.lastVisibleActionCreated && b.lastVisibleActionCreated ? compareStringDates(b.lastVisibleActionCreated, a.lastVisibleActionCreated) : 0;
const compareDisplayNames = a.displayName && b.displayName ? a.displayName.localeCompare(b.displayName) : 0;
return compareDates || compareDisplayNames;
});
// For archived reports, ensure most recent reports are at the top by reversing the order
archivedReports.sort((a, b) => (a.lastVisibleActionCreated && b.lastVisibleActionCreated ? compareStringDates(b.lastVisibleActionCreated, a.lastVisibleActionCreated) : 0));
} else {
// Sort non-archived and archived reports alphabetically
nonArchivedReports.sort((a, b) => (a.displayName && b.displayName ? a.displayName.localeCompare(b.displayName) : 0));
archivedReports.sort((a, b) => (a.displayName && b.displayName ? a.displayName.localeCompare(b.displayName) : 0));
}
// Combine all groups into a single array for final sorting
const allReportsSorted: Report[] = [...pinnedAndGBRReports, ...draftReports, ...nonArchivedReports, ...archivedReports];
// Sort the combined array based on specified criteria
allReportsSorted.sort((a, b) => {
const comparePinned = (b.isPinned ? 1 : 0) - (a.isPinned ? 1 : 0);
const compareDisplayNames = a.displayName && b.displayName ? a.displayName.localeCompare(b.displayName) : 0;
const compareDates = a.lastVisibleActionCreated && b.lastVisibleActionCreated ? compareStringDates(b.lastVisibleActionCreated, a.lastVisibleActionCreated) : 0;
// First, sort by pinned status, then by display names, and finally by dates in most recent mode
return comparePinned || compareDisplayNames || compareDates;
});
// Extract reportIDs from the final sorted array
const LHNReports = allReportsSorted.map((report) => report.reportID);
// Update the cache with the sorted reportIDs
setWithLimit(reportIDsCache, cachedReportsKey, LHNReports);
return LHNReports;
}
// Function to compare string dates
function compareStringDates(dateStringA: string, dateStringB: string): number {
const dateA = new Date(dateStringA);
const dateB = new Date(dateStringB);
return dateB.getTime() - dateA.getTime();
}
The current sorting logic in the Last Heard Navigation (LHN) feature doesn't handle non-alphanumeric characters appropriately when sorting alphabetically. The requirement is to ignore these characters during alphabetical sorting for both "Pinned/GBR Reports" and "Draft Reports." Proposed Changes:1. Handling Non-Alphanumeric Characters:
pinnedAndGBRReports.sort((a, b) => {
const cleanA = a?.displayName?.replace(/[^0-9a-zA-Z]/g, '');
const cleanB = b?.displayName?.replace(/[^0-9a-zA-Z]/g, '');
return cleanA && cleanB ? cleanA.localeCompare(cleanB) : 0;
});
draftReports.sort((a, b) => {
const cleanA = a?.displayName?.replace(/[^0-9a-zA-Z]/g, '');
const cleanB = b?.displayName?.replace(/[^0-9a-zA-Z]/g, '');
return cleanA && cleanB ? cleanA.localeCompare(cleanB) : 0;
}); 2. Verification of GBR and RBR:
// ... (previous code)
// Sort each group of reports accordingly
pinnedAndGBRReports.sort((a, b) => {
const cleanA = a.displayName?.replace(/[^0-9a-zA-Z]/g, '');
const cleanB = b.displayName?.replace(/[^0-9a-zA-Z]/g, '');
return cleanA && cleanB ? cleanA.localeCompare(cleanB) : 0;
});
draftReports.sort((a, b) => {
const cleanA = a.displayName?.replace(/[^0-9a-zA-Z]/g, '');
const cleanB = b.displayName?.replace(/[^0-9a-zA-Z]/g, '');
return cleanA && cleanB ? cleanA.localeCompare(cleanB) : 0;
});
// ... (remaining code)
// Sort the combined array based on specified criteria
allReportsSorted.sort((a, b) => {
const comparePinned = (b.isPinned ? 1 : 0) - (a.isPinned ? 1 : 0);
const compareDisplayNames = a.displayName && b.displayName ? a.displayName.localeCompare(b.displayName) : 0;
const compareDates = a.lastVisibleActionCreated && b.lastVisibleActionCreated ? compareStringDates(b.lastVisibleActionCreated, a.lastVisibleActionCreated) : 0;
// First, sort by pinned status, then by display names, and finally by dates in most recent mode
return comparePinned || compareDisplayNames || compareDates;
});
// ... (remaining code) Benefits:
|
📣 @thebigshotsam! 📣
|
Added some minor comment in the proposal. |
@JmillsExpensify @fedirjh this issue is now 4 weeks old and preventing us from maintaining WAQ, can you:
Thanks! |
Current assignee @fedirjh is eligible for the Internal assigner, not assigning anyone new. |
What are the next steps? Who are we waiting on, and what are waiting on them to do? |
Nex steps should be reviewing the proposals. |
@youssef-lr The PR was reverted here #38081 due to performance issues. We again need to raise a PR to fix the same. |
Bummer. How about we make pinning RBR reports only rely on the transaction violations coming from the violations onyx key? I think the performance hit is coming from the fact that we iterate over all report actions to find out if they have an error. The errors stored in the report actions are just API errors, which I think are rare. |
Maybe make some BE changes to get the error from these actions reflected in the report itself. This will help us to get RBR without going through reportActions. |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
Payment Summary
BugZero Checklist (@JmillsExpensify)
|
Removing the payment from title as we still work on the implementation. |
@JmillsExpensify, @youssef-lr, @luacmartins, @fedirjh, @shubham1206agra 12 days overdue. Walking. Toward. The. Light... |
This issue has not been updated in over 14 days. @JmillsExpensify, @youssef-lr, @luacmartins, @fedirjh, @shubham1206agra eroding to Weekly issue. |
This issue has not been updated in over 15 days. @JmillsExpensify, @youssef-lr, @luacmartins, @fedirjh, @shubham1206agra eroding to Monthly issue. P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do! |
@youssef-lr Can we restart discussion on this issue? |
Yes I think we should. I'll get back to you this week @shubham1206agra as I'm busying finalizing a new feature. |
What's the latest here? I think we merged a fix for this issue and it's done? Are we missing payments? |
@luacmartins we need to redo the fix, it caused performance issues and we reverted it. |
@youssef-lr Should we redo the fix now? Or is something blocking us now? |
I think let's redo it and see if reassure-perf complains |
@JmillsExpensify, @youssef-lr, @luacmartins, @fedirjh, @shubham1206agra, this Monthly task hasn't been acted upon in 6 weeks; closing. If you disagree, feel encouraged to reopen it -- but pick your least important issue to close instead. |
@youssef-lr Please repoen this. |
Problem:
When the LHN is in "focus" mode, its sorting should be:
However, it doesn't seem to be. Here's from @iwiznia:
Solution:
Review the LHN logic for sorting in focus mode to understand what it's currently doing, and verify it's correct. The correct behavior should be:
#focus mode:
most recent mode:
Additionally:
So, for this issue please:
You up to the challenge? Let's see those proposals!!
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @youssef-lrThe text was updated successfully, but these errors were encountered: