feat: add policyReportFields to the policy object directly#36553
Conversation
|
@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@Expensify/contributor-plus anyone who first comment here please take over. |
|
I can! |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid-app-2024-03-20_16.14.21.mp4Android: mWeb Chromeandroid-chrome-2024-03-20_16.25.42.mp4iOS: Nativeios-app-2024-03-20_15.51.30.mp4iOS: mWeb Safariios-safari-2024-03-20_14.44.59.mp4MacOS: Chrome / Safaridesktop-chrome-2024-03-20_15.46.57.mp4MacOS: Desktopdesktop-app-2024-03-20_16.04.08.mp4 |
Co-authored-by: Joel Davies <joeld.dev@gmail.com>
|
@allroundexperts I guess we don't support disabling dropdown options here yet? If I disable a bunch on OD it doesn't have any effect on ND. |
@allroundexperts I guess this step is no longer relevant. |
I don't remember adding it although @thienlnam can confirm. |
|
Just a note that the BE still doesn't seem to be sending pusher updates when fields are deleted in OD, so it requires signing out & back in for those changes to show. |
|
chrome-pusher-2024-03-20_16.08.20.mp4 |
|
@jjcoffee Can you please share the url you see at top when the not found page is seen? |
|
Looks to me like the pusher is sending back the fields without the expensify prefix. |
@allroundexperts Bingo! |
|
Ah actually it's the same URL that gets opened after refresh. |
|
Can you check what pusher sends back when you add a field? |
|
Looks like it only updates the fields on the policy, not the report. "updates": [
{
"data": [
{
"key": "policy_6D05DA21B79C2F3A",
"onyxMethod": "merge",
"value": {
"fieldList": {
"field_id_TESTING_PUSHER": {
"defaultExternalID": null,
"defaultValue": null,
"deletable": false,
"disabledOptions": [],
"externalID": null,
"externalIDs": [],
"fieldID": "field_id_TESTING_PUSHER",
"isTax": false,
"keys": [],
"name": "Testing Pusher",
"orderWeight": 4,
"origin": null,
"target": "expense",
"type": "text",
"value": null,
"values": []
}
}
}
}
],
"eventType": "onyxApiUpdate"
} |
|
That's fine. The issue is that pusher is not appending |
|
Ah yeah I see the policy has duplicate fields with/without the |
jjcoffee
left a comment
There was a problem hiding this comment.
LGTM! There's just a BE fix required to the pusher updates (see this comment), but that doesn't need to block this PR.
thienlnam
left a comment
There was a problem hiding this comment.
Awesome - thanks for this!
|
✋ 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/thienlnam in version: 1.4.56-0 🚀
|
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.4.56-8 🚀
|
| fieldName={Str.UCFirst(reportField.name)} | ||
| fieldValue={fieldValue} | ||
| fieldOptions={reportField.values} | ||
| fieldOptions={reportField.values.filter((value) => !(value in reportField.disabledOptions))} |
There was a problem hiding this comment.
This was not the right way to check if a value is in an array in javascript. It caused this deploy blocker: #38898
There was a problem hiding this comment.
Ugh... I hate when this happens 😢. I was super sure that this won't happen again.
| * Get the key for a report field | ||
| */ | ||
| function getReportFieldKey(reportFieldId: string) { | ||
| return `expensify_${reportFieldId}`; |
There was a problem hiding this comment.
Adding expensify_ prefix to all fieldID cause a problem with the title fieldID text_title which shouldn't have this prefix, and we dealt with in #40464
| fieldName={Str.UCFirst(reportField.name)} | ||
| fieldValue={fieldValue} | ||
| fieldOptions={reportField.values} | ||
| fieldOptions={reportField.values.filter((value) => !(value in reportField.disabledOptions))} |
There was a problem hiding this comment.
Here, we should have used policyField instead of reportField.
Issue: #48827
| ReportActions.updateReportName(report.reportID, value, report.reportName ?? ''); | ||
| } else { | ||
| ReportActions.updateReportField(report.reportID, {...reportField, value}, reportField); | ||
| ReportActions.updateReportField(report.reportID, {...reportField, value: value === '' ? null : value}, reportField); |
There was a problem hiding this comment.
We should check the value exist before updating the report field. Ref: #47067
Details
This PR adds the policy report fields to the policy object itself instead of a separate
policyFields_idobject.Fixed Issues
$ #36170
PROPOSAL: N/A
Tests
canUseReportFieldsbeta is enabled.Offline tests
Same as above. Verify that everything works in offline mode.
QA Steps
canUseReportFieldsbeta is enabled.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
Android: Native
Screen.Recording.2024-03-20.at.5.50.33.PM.mov
Android: mWeb Chrome
Screen.Recording.2024-03-20.at.5.49.51.PM.mov
iOS: Native
Screen.Recording.2024-03-20.at.5.48.23.PM.mov
iOS: mWeb Safari
Screen.Recording.2024-03-20.at.5.46.56.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2024-03-20.at.5.42.37.PM.mov
MacOS: Desktop
Screen.Recording.2024-03-20.at.5.44.59.PM.mov