-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix: The order of selected workspace and selected report are inconsistent #65248
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
Merged
cristipaval
merged 8 commits into
Expensify:main
from
etCoderDysto:sort_outstanding_report
Jul 14, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1238c32
create a function that sorts outstanding reports by selected id
etCoderDysto 465c0fd
add comment for the sort function
etCoderDysto 9cf25a8
sort the report on EditReportCommon page
etCoderDysto e694f27
Merge branch 'main' into sort_outstanding_report
etCoderDysto e777f71
add a unit test for sortOutstandingReportsBySelected
etCoderDysto 4a3e541
remove only call used to isolate new test
etCoderDysto 81f525c
merge main to feature branch
etCoderDysto 9bfea88
merge main to fix branch
etCoderDysto 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 hidden or 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 |
|---|---|---|
|
|
@@ -886,7 +886,7 @@ | |
| const parsedReportActionMessageCache: Record<string, string> = {}; | ||
|
|
||
| let conciergeReportID: OnyxEntry<string>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.CONCIERGE_REPORT_ID, | ||
| callback: (value) => { | ||
| conciergeReportID = value; | ||
|
|
@@ -894,7 +894,7 @@ | |
| }); | ||
|
|
||
| const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon'; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.SESSION, | ||
| callback: (value) => { | ||
| // When signed out, val is undefined | ||
|
|
@@ -912,7 +912,7 @@ | |
| let allPersonalDetails: OnyxEntry<PersonalDetailsList>; | ||
| let allPersonalDetailLogins: string[]; | ||
| let currentUserPersonalDetails: OnyxEntry<PersonalDetails>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| callback: (value) => { | ||
| if (currentUserAccountID) { | ||
|
|
@@ -924,14 +924,14 @@ | |
| }); | ||
|
|
||
| let allReportsDraft: OnyxCollection<Report>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_DRAFT, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => (allReportsDraft = value), | ||
| }); | ||
|
|
||
| let allPolicies: OnyxCollection<Policy>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.POLICY, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => (allPolicies = value), | ||
|
|
@@ -939,7 +939,7 @@ | |
|
|
||
| let allReports: OnyxCollection<Report>; | ||
| let reportsByPolicyID: ReportByPolicyMap; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -976,14 +976,14 @@ | |
| }); | ||
|
|
||
| let allBetas: OnyxEntry<Beta[]>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.BETAS, | ||
| callback: (value) => (allBetas = value), | ||
| }); | ||
|
|
||
| let allTransactions: OnyxCollection<Transaction> = {}; | ||
| let reportsTransactions: Record<string, Transaction[]> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.TRANSACTION, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -1009,7 +1009,7 @@ | |
| }); | ||
|
|
||
| let allReportActions: OnyxCollection<ReportActions>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, | ||
| waitForCollectionCallback: true, | ||
| callback: (actions) => { | ||
|
|
@@ -1022,7 +1022,7 @@ | |
|
|
||
| let allReportMetadata: OnyxCollection<ReportMetadata>; | ||
| const allReportMetadataKeyValue: Record<string, ReportMetadata> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_METADATA, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -10044,6 +10044,22 @@ | |
| .sort((a, b) => a?.reportName?.localeCompare(b?.reportName?.toLowerCase() ?? '') ?? 0); | ||
| } | ||
|
|
||
| /** | ||
| * Sort outstanding reports by their name, while keeping the selected one at the beginning. | ||
| * @param report1 Details of the first report to be compared. | ||
| * @param report2 Details of the second report to be compared. | ||
| * @param selectedReportID ID of the selected report which needs to be at the beginning. | ||
| */ | ||
| function sortOutstandingReportsBySelected(report1: OnyxEntry<Report>, report2: OnyxEntry<Report>, selectedReportID: string | undefined): number { | ||
| if (report1?.reportID === selectedReportID) { | ||
| return -1; | ||
| } | ||
| if (report2?.reportID === selectedReportID) { | ||
| return 1; | ||
| } | ||
| return report1?.reportName?.localeCompare(report2?.reportName?.toLowerCase() ?? '') ?? 0; | ||
|
Contributor
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. Coming from #72039, we should sort the reports by created date to be consistent with Reports page. |
||
| } | ||
|
|
||
| /** | ||
| * @returns the object to update `report.hasOutstandingChildRequest` | ||
| */ | ||
|
|
@@ -11435,6 +11451,7 @@ | |
| shouldReportBeInOptionList, | ||
| shouldReportShowSubscript, | ||
| shouldShowFlagComment, | ||
| sortOutstandingReportsBySelected, | ||
| getReportActionWithMissingSmartscanFields, | ||
| shouldShowRBRForMissingSmartscanFields, | ||
| shouldUseFullTitleToDisplay, | ||
|
|
||
This file contains hidden or 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 hidden or 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
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.
Can you add unit tests for this function?
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 have added a unit test.