Skip to content

Commit

Permalink
Rename functions to separate UI from function logic
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetlath committed Oct 31, 2023
1 parent 056b7d5 commit 943bc80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1330,12 +1330,12 @@ function getLastVisibleMessage(reportID, actionsToMerge = {}) {
* @param {Object} parentReportAction - The parent report action of the report (Used to check if the task has been canceled)
* @returns {Boolean}
*/
function isWaitingForTaskCompleteFromAssignee(report, parentReportAction = {}) {
function isWaitingForAssigneeToCompleteTask(report, parentReportAction = {}) {
return isTaskReport(report) && isReportManager(report) && isOpenTaskReport(report, parentReportAction);
}

/**
* Determines if a report should show a GBR (green dot) in the LHN. This can happen when the report:
* Determines if a report requires action from the current user. 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)
Expand All @@ -1344,7 +1344,7 @@ function isWaitingForTaskCompleteFromAssignee(report, parentReportAction = {}) {
* @param {Object} parentReportAction (the report action the current report is a thread of)
* @returns {boolean}
*/
function shouldShowGBR(report, parentReportAction = {}) {
function requiresAttentionFromCurrentUser(report, parentReportAction = {}) {
if (!report) {
return false;
}
Expand All @@ -1357,7 +1357,7 @@ function shouldShowGBR(report, parentReportAction = {}) {
return true;
}

if (isWaitingForTaskCompleteFromAssignee(report, parentReportAction)) {
if (isWaitingForAssigneeToCompleteTask(report, parentReportAction)) {
return true;
}

Expand Down Expand Up @@ -3287,7 +3287,7 @@ function shouldReportBeInOptionList(report, currentReportId, isInGSDMode, betas,
}

// Include reports that are relevant to the user in any view mode. Criteria include having a draft or having a GBR showing.
if (report.hasDraft || shouldShowGBR(report)) {
if (report.hasDraft || requiresAttentionFromCurrentUser(report)) {
return true;
}
const lastVisibleMessage = ReportActionsUtils.getLastVisibleMessage(report.reportID);
Expand Down Expand Up @@ -4145,7 +4145,7 @@ export {
isCurrentUserTheOnlyParticipant,
hasAutomatedExpensifyAccountIDs,
hasExpensifyGuidesEmails,
shouldShowGBR,
requiresAttentionFromCurrentUser,
isIOUOwnedByCurrentUser,
getMoneyRequestReimbursableTotal,
getMoneyRequestSpendBreakdown,
Expand Down Expand Up @@ -4265,7 +4265,7 @@ export {
hasNonReimbursableTransactions,
hasMissingSmartscanFields,
getIOUReportActionDisplayMessage,
isWaitingForTaskCompleteFromAssignee,
isWaitingForAssigneeToCompleteTask,
isGroupChat,
isReportDraft,
shouldUseFullTitleToDisplay,
Expand Down
3 changes: 1 addition & 2 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function getOrderedReportIDs(
const archivedReports: Report[] = [];
reportsToDisplay.forEach((report) => {
const isPinned = report.isPinned ?? false;
if (isPinned || ReportUtils.shouldShowGBR(report)) {
if (isPinned || ReportUtils.requiresAttentionFromCurrentUser(report)) {
pinnedAndGBRReports.push(report);
} else if (report.hasDraft) {
draftReports.push(report);
Expand Down Expand Up @@ -260,7 +260,6 @@ type OptionData = {
isAllowedToComment?: boolean | null;
isThread?: boolean | null;
isTaskReport?: boolean | null;
isWaitingForTaskCompleteFromAssignee?: boolean | null;
parentReportID?: string | null;
parentReportAction?: ReportAction;
notificationPreference?: string | number | null;
Expand Down

0 comments on commit 943bc80

Please sign in to comment.