-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[NoQA] Add policyID to getOrderedReportIDs and sortReportsByLastRead #33302
Merged
mountiny
merged 18 commits into
Expensify:main
from
software-mansion-labs:filter-out-reports-by-workspace
Jan 18, 2024
Merged
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
68bc20b
Add policyID to getOrderedReportIDs and sortReportsByLastRead
WojtekBoman 3519aa3
Refactor getOrderedReportIDs function
WojtekBoman fd51ac7
Refactor getOrderedReportIDs function
WojtekBoman 7c9f4f3
Merge branch 'main' into filter-out-reports-by-workspace
WojtekBoman 56b1bbe
Merge branch 'main' into filter-out-reports-by-workspace
WojtekBoman baf40b7
Add openWorkspace request
WojtekBoman 2788c74
Add policyID and policyMemberAccountIDs params to findLastAccessedReport
WojtekBoman df65140
Merge branch 'main' into filter-out-reports-by-workspace
WojtekBoman 269cde1
Refactor doesReportBelongToWorkspace function
WojtekBoman a92114a
Refactor getOrderedReportIDs function
WojtekBoman 03fcbd8
Update sortReportsByLastRead description
WojtekBoman 8f398a6
Additional check for Concierge in doesReportBelongToWorkspace
WojtekBoman 94b6a69
Fix policyMemberAccountIDs types
WojtekBoman af744fd
Refactor function names and descriptions
WojtekBoman 12ef275
Merge branch 'main' into filter-out-reports-by-workspace
WojtekBoman 57bda5c
Add filterReportsByPolicyIdAndMemberAccountIDs function
WojtekBoman 2c9b08f
Refactor function params and descriptions
WojtekBoman 76cda90
Add openWorkspace docs
WojtekBoman 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,11 +118,12 @@ function getOrderedReportIDs( | |
policies: Record<string, Policy>, | ||
priorityMode: ValueOf<typeof CONST.PRIORITY_MODE>, | ||
allReportActions: OnyxCollection<ReportAction[]>, | ||
currentPolicyID = '', | ||
): string[] { | ||
// Generate a unique cache key based on the function arguments | ||
const cachedReportsKey = JSON.stringify( | ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
[currentReportId, allReports, betas, policies, priorityMode, allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentReportId}`]?.length || 1], | ||
[currentPolicyID, currentReportId, allReports, betas, policies, priorityMode, allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentReportId}`]?.length || 1], | ||
(key, value: unknown) => { | ||
/** | ||
* Exclude 'participantAccountIDs', 'participants' and 'lastMessageText' not to overwhelm a cached key value with huge data, | ||
|
@@ -149,7 +150,7 @@ function getOrderedReportIDs( | |
const isInDefaultMode = !isInGSDMode; | ||
const allReportsDictValues = Object.values(allReports); | ||
// Filter out all the reports that shouldn't be displayed | ||
const reportsToDisplay = allReportsDictValues.filter((report) => ReportUtils.shouldReportBeInOptionList(report, currentReportId ?? '', isInGSDMode, betas, policies, true)); | ||
let reportsToDisplay = allReportsDictValues.filter((report) => ReportUtils.shouldReportBeInOptionList(report, currentReportId ?? '', isInGSDMode, betas, policies, true)); | ||
|
||
if (reportsToDisplay.length === 0) { | ||
// Display Concierge chat report when there is no report to be displayed | ||
|
@@ -173,6 +174,10 @@ function getOrderedReportIDs( | |
const nonArchivedReports: Report[] = []; | ||
const archivedReports: Report[] = []; | ||
|
||
if (currentPolicyID) { | ||
reportsToDisplay = reportsToDisplay.filter((report) => report.policyID === currentPolicyID); | ||
} | ||
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. Hi 👋 Coming from #35963 When the IOU report and details page are not highlighted in the LHN, the filter removes the current viewed report. So to fix it we decided to add a check where it's past the currently viewed report. |
||
|
||
// There are a few properties that need to be calculated for the report which are used when sorting reports. | ||
reportsToDisplay.forEach((report) => { | ||
// Normally, the spread operator would be used here to clone the report and prevent the need to reassign the params. | ||
|
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.