-
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
[HOLD] Feat: Update how GBR is determined for IOU/expense reports #29778
Changes from all commits
cb3f3d0
ddba0ec
4fca049
7523bd6
b8b6752
f6b79e6
f4cb009
63f6bd8
647efb8
de9e121
2bb9228
bfb06ae
a9c9ef2
0ce0891
dd4a7bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1324,12 +1324,15 @@ function getLastVisibleMessage(reportID, actionsToMerge = {}) { | |
} | ||
|
||
/** | ||
* Determines if a report has an IOU that is waiting for an action from the current user (either Pay or Add a credit bank account) | ||
* Determines if a report should show a GBR (green dot) in the LHN. This can happen when the report: | ||
- is unread and the user was mentioned in one of the unread comments | ||
- is for an outstanding task waiting on the user | ||
- has an outstanding child money request that is waiting for an action from the current user (e.g. pay, approve, add bank account) | ||
* | ||
* @param {Object} report (chatReport or iouReport) | ||
* @returns {boolean} | ||
*/ | ||
function isWaitingForIOUActionFromCurrentUser(report) { | ||
function shouldShowGBR(report) { | ||
if (!report) { | ||
return false; | ||
} | ||
|
@@ -1338,20 +1341,8 @@ function isWaitingForIOUActionFromCurrentUser(report) { | |
return false; | ||
} | ||
|
||
const policy = getPolicy(report.policyID); | ||
if (policy.type === CONST.POLICY.TYPE.CORPORATE) { | ||
// If the report is already settled, there's no action required from any user. | ||
if (isSettled(report.reportID)) { | ||
return false; | ||
} | ||
|
||
// Report is pending approval and the current user is the manager | ||
if (isReportManager(report) && !isReportApproved(report)) { | ||
return true; | ||
} | ||
|
||
// Current user is an admin and the report has been approved but not settled yet | ||
return policy.role === CONST.POLICY.ROLE.ADMIN && isReportApproved(report); | ||
if (report.isUnreadWithMention) { | ||
return true; | ||
} | ||
|
||
// Money request waiting for current user to add their credit bank account | ||
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. @waterim actually, we've decided to treat this condition like the others. If a report is waiting on bank account, we will add the 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. @waterim I think we should remove this whole block:
|
||
|
@@ -1360,8 +1351,8 @@ function isWaitingForIOUActionFromCurrentUser(report) { | |
return true; | ||
} | ||
|
||
// Money request waiting for current user to Pay (from expense or iou report) | ||
if (report.hasOutstandingIOU && report.ownerAccountID && (report.ownerAccountID !== currentUserAccountID || currentUserAccountID === report.managerID)) { | ||
// Has a child report that is awaiting action (e.g. approve, pay, add bank account) from current user | ||
if (report.hasOutstandingChildRequest) { | ||
return true; | ||
} | ||
|
||
|
@@ -3297,7 +3288,7 @@ function shouldReportBeInOptionList(report, currentReportId, isInGSDMode, betas, | |
} | ||
|
||
// Include reports that are relevant to the user in any view mode. Criteria include having a draft, having an outstanding IOU, or being assigned to an open task. | ||
if (report.hasDraft || isWaitingForIOUActionFromCurrentUser(report) || isWaitingForTaskCompleteFromAssignee(report)) { | ||
if (report.hasDraft || shouldShowGBR(report) || isWaitingForTaskCompleteFromAssignee(report)) { | ||
waterim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return true; | ||
} | ||
const lastVisibleMessage = ReportActionsUtils.getLastVisibleMessage(report.reportID); | ||
|
@@ -4155,7 +4146,7 @@ export { | |
isCurrentUserTheOnlyParticipant, | ||
hasAutomatedExpensifyAccountIDs, | ||
hasExpensifyGuidesEmails, | ||
isWaitingForIOUActionFromCurrentUser, | ||
shouldShowGBR, | ||
isIOUOwnedByCurrentUser, | ||
getMoneyRequestReimbursableTotal, | ||
getMoneyRequestSpendBreakdown, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,7 +170,6 @@ function getOrderedReportIDs( | |
|
||
// The LHN is split into five distinct groups, and each group is sorted a little differently. The groups will ALWAYS be in this order: | ||
// 1. Pinned - Always sorted by reportDisplayName | ||
// 2. Outstanding IOUs - Always sorted by iouReportAmount with the largest amounts at the top of the group | ||
// 3. Drafts - Always sorted by reportDisplayName | ||
// 4. Non-archived reports and settled IOUs | ||
// - Sorted by lastVisibleActionCreated in default (most recent) view mode | ||
|
@@ -179,15 +178,12 @@ function getOrderedReportIDs( | |
// - Sorted by lastVisibleActionCreated in default (most recent) view mode | ||
// - Sorted by reportDisplayName in GSD (focus) view mode | ||
const pinnedReports: Report[] = []; | ||
const outstandingIOUReports: Report[] = []; | ||
const draftReports: Report[] = []; | ||
const nonArchivedReports: Report[] = []; | ||
const archivedReports: Report[] = []; | ||
reportsToDisplay.forEach((report) => { | ||
if (report.isPinned) { | ||
if (report.isPinned ?? ReportUtils.shouldShowGBR(report)) { | ||
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. Why 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. New lint rules |
||
pinnedReports.push(report); | ||
} else if (ReportUtils.isWaitingForIOUActionFromCurrentUser(report)) { | ||
outstandingIOUReports.push(report); | ||
} else if (report.hasDraft) { | ||
draftReports.push(report); | ||
} else if (ReportUtils.isArchivedRoom(report)) { | ||
|
@@ -199,11 +195,6 @@ function getOrderedReportIDs( | |
|
||
// Sort each group of reports accordingly | ||
pinnedReports.sort((a, b) => (a?.displayName && b?.displayName ? a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()) : 0)); | ||
outstandingIOUReports.sort((a, b) => { | ||
const compareAmounts = a?.iouReportAmount && b?.iouReportAmount ? b.iouReportAmount - a.iouReportAmount : 0; | ||
const compareDisplayNames = a?.displayName && b?.displayName ? a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()) : 0; | ||
return compareAmounts || compareDisplayNames; | ||
}); | ||
draftReports.sort((a, b) => (a?.displayName && b?.displayName ? a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()) : 0)); | ||
|
||
if (isInDefaultMode) { | ||
|
@@ -221,7 +212,7 @@ 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 = [...pinnedReports, ...outstandingIOUReports, ...draftReports, ...nonArchivedReports, ...archivedReports].map((report) => report.reportID); | ||
const LHNReports = [...pinnedReports, ...draftReports, ...nonArchivedReports, ...archivedReports].map((report) => report.reportID); | ||
setWithLimit(reportIDsCache, cachedReportsKey, LHNReports); | ||
return LHNReports; | ||
} | ||
|
@@ -254,6 +245,7 @@ type OptionData = { | |
searchText?: string | null; | ||
isPinned?: boolean | null; | ||
hasOutstandingIOU?: boolean | null; | ||
hasOutstandingChildRequest?: boolean | null; | ||
iouReportID?: string | null; | ||
isIOUReportOwner?: boolean | null; | ||
iouReportAmount?: number | null; | ||
|
@@ -338,6 +330,7 @@ function getOptionData( | |
searchText: null, | ||
isPinned: false, | ||
hasOutstandingIOU: false, | ||
hasOutstandingChildRequest: false, | ||
iouReportID: null, | ||
isIOUReportOwner: null, | ||
iouReportAmount: 0, | ||
|
@@ -382,6 +375,7 @@ function getOptionData( | |
result.keyForList = String(report.reportID); | ||
result.tooltipText = ReportUtils.getReportParticipantsTitle(report.participantAccountIDs ?? []); | ||
result.hasOutstandingIOU = report.hasOutstandingIOU; | ||
result.hasOutstandingChildRequest = report.hasOutstandingChildRequest; | ||
result.parentReportID = report.parentReportID ?? null; | ||
result.isWaitingOnBankAccount = report.isWaitingOnBankAccount; | ||
result.notificationPreference = report.notificationPreference ?? null; | ||
|
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.
I don't see the task case covered in the function. Shouldn't it be?