[NoQA] Add policyID to getOrderedReportIDs and sortReportsByLastRead#33302
Conversation
|
Thank you for opening the PR @WojtekBoman while I'm still working the backend API 🙇 I like how you're working on things you can work on right now 🙇 |
|
|
||
| /** | ||
| * Given a collection of reports returns them sorted by last read | ||
| * Given a collection of reports returns them sorted by last read and optionally filtered by a specific policyID. |
There was a problem hiding this comment.
| * Given a collection of reports returns them sorted by last read and optionally filtered by a specific policyID. | |
| * Given a collection of reports, return them sorted by the last read timestamp. Filters the sorted reports by a policy ID, if provided. |
|
All comments have been resolved :) |
|
@WojtekBoman sorry for the wait 🙇 I'm back from OOO another internal engineer took over the task of creating the backend API. I'll give you update as that progresses 🙇 |
|
The backend API has been deployed to the staging environment. I will notify you when it is deployed to production. The new API is named OpenWorkspace. |
|
wait, I think the NewDot talks to the staging server right? if that is the case, you can already test your PR if you need the new API to do so. @WojtekBoman |
|
Let us know in slack when this is ready, we can merge to the feature branch |
| let reportsValues = Object.values(reports ?? {}); | ||
| if (policyID) { | ||
| reportsValues = reportsValues.filter((report) => !!report && doesReportBelongToWorkspace(report, policyID, policyMemberAccountIDs)); | ||
| } |
There was a problem hiding this comment.
Should we move this before the sortReportsByLastRead method/ outside? This is now changing the purpose of the method which was only to sort so I fee like any filtering should be done before that and we only pass the collection of the reports we know we want to sort
There was a problem hiding this comment.
I've created the separated method to filter reports which is invoked before the sortReportsByLastRead, but to achieve that I had to move parsing OnyxCollection to the array to the parent function. Is it ok? This change required adjusting types in the function params.
hayata-suenaga
left a comment
There was a problem hiding this comment.
finally got around reviewing this 😓 code looks good to me 🟢
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
|
|
||
| type OpenWorkspaceParams = { | ||
| policyID: string; | ||
| clientMemberEmails: string; |
There was a problem hiding this comment.
| clientMemberEmails: string; | |
| clientMemberAccountIDs: string; |
|
|
||
| const params: OpenWorkspaceParams = { | ||
| policyID, | ||
| clientMemberEmails: JSON.stringify(clientMemberAccountIDs), |
There was a problem hiding this comment.
| clientMemberEmails: JSON.stringify(clientMemberAccountIDs), | |
| clientMemberAccountIDs: JSON.stringify(clientMemberAccountIDs), |
| API.read('OpenWorkspaceReimburseView', params, {successData, failureData}); | ||
| } | ||
|
|
||
| function openWorkspace(policyID: string, clientMemberAccountIDs: number[]) { |
There was a problem hiding this comment.
Cuold you add docs here to explain what is returned in this case?
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 1.4.28-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.28-0 🚀
|
|
|
||
| if (currentPolicyID || policyMemberAccountIDs.length > 0) { | ||
| reportsToDisplay = reportsToDisplay.filter((report) => ReportUtils.doesReportBelongToWorkspace(report, currentPolicyID, policyMemberAccountIDs)); | ||
| } |
There was a problem hiding this comment.
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.

Details
In this PR have been modified two functions. To both of them has been added an additional param: policyID. The modified functions:
When the workspace switcher is ready, the appropriate policyID should be passed to the functions listed above.
cc: @hayata-suenaga
Fixed Issues
$ #31877
PROPOSAL: described in the design doc: https://docs.google.com/document/d/1VnEf2ThbbiQj0kx9KnAihF0DWf50s2Bn_MztEyEwtjg/edit?pli=1#bookmark=id.v253hbgx14pm
Tests
To test whether filtering works properly, pass an example policyID to the functions mentioned above, and check if the returned data is associated with the workspace whose ID was passed to the function.
Offline tests
To test whether filtering works properly, pass an example policyID to the functions mentioned above, and check if the returned data is associated with the workspace whose ID was passed to the function.
QA Steps
To test whether filtering works properly, pass an example policyID to the functions mentioned above, and check if the returned data is associated with the workspace whose ID was passed to the function.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel so the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
This PR only modifies utility functions.
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop