-
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
feat: Integrate report fields with backend #34483
Conversation
@sobitneupane 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] |
Hi @sobitneupane! |
@allroundexperts I won't be able to review it soon. So, can we get someone else assigned? |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid-native-2024-01-22_16.53.24.mp4Android: mWeb Chromeandroid-chrome-2024-01-22_16.41.02.mp4iOS: Nativeios-native-2024-01-22_17.01.51.mp4iOS: mWeb Safariios-safari-2024-01-22_17.06.03.mp4MacOS: Chrome / Safaridesktop-chrome-2024-01-22_17.08.48.mp4MacOS: Desktopdesktop-app-2024-01-22_17.21.49.mp4 |
@allroundexperts Could you add an Android native screenshot? |
@jjcoffee I am having issues with Android build. I think testing on web should be sufficient, no? |
src/pages/EditReportFieldPage.tsx
Outdated
const reportFieldValue = report?.reportFields?.[policyReportField?.fieldID ?? '']; | ||
|
||
// Decides whether to allow or disallow editing a money request | ||
useEffect(() => {}, []); |
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.
Maybe tidy this away for now?
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.
Doesn't really matter. It would be filled in an upcoming PR anyways. I think this would be a reminder to not miss this case!
@allroundexperts Testing well! I guess the relevant changes for |
That's correct! |
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.
Looking good, just one small comment
src/pages/EditReportFieldPage.tsx
Outdated
}; | ||
|
||
if (policyReportField) { | ||
if (policyReportField.type === 'text' || policyReportField.type === 'formula') { |
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 we create constants for these report field types?
I will make an issue so that openReport returns the report fields - I thought it returned all report NVPS but let me double check |
src/libs/actions/Report.ts
Outdated
reportID, | ||
reportFields: JSON.stringify({[policyField.fieldID]: {fieldID: policyField.fieldID, value: fieldValue, type: policyField.type, name: policyField.name}}), | ||
}; |
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 we include all values from the policyField at this time? When OpenReport passes back the reports, it will have a reportField list that contains the reportFields at the time of creation.
So if the weights change later, this report should have the same report fields weights at the time of storage for historical context
This comment was marked as resolved.
This comment was marked as resolved.
@thienlnam That exists already. One thing to note is that for the reports, we don't really need the full reportField object. That object exists in the policy already so I don't see any point in duplicating that into reports everywhere. We should just store the value of the field in the report. |
This doesn't seem to have anything to do with the code of this PR. I think we can ignore this here. |
Agreed, I guess it's an Onyx issue. I retested on a smaller report and it's much faster. |
We do this because we store the report fields at the time the report was created. For example, if you had some report fields, all expense reports would use those fields. If you decided to change all of your report fields, you don't actually want it to change on your previous submitted reports. Those will retain the report fields that were already set. If we only had the object in the policy, we wouldn't have a way to see the old set report fields on an older report |
I thought we discussed this at some point and decided to use the fields stored in the policy as a single source of truth. However, if we need to change that, then the backend will need to ensure that for an open report (one that hasn't been settled), the fields attached to a report are in sync with the fields that are attached to the policy. Given this, do you think I should do the changes in this PR or as a separate issue? |
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.
Nice - this looks solid! Thanks
@jjcoffee There's been a lot that has changed in this PR since your original review, could you please do another review / quick round of testing just to make sure none of the changes add any blockers? |
Additionally, @allroundexperts could you please update the QA steps with the these instructions #34889 (comment) so that applause can test this when it goes to staging? |
Sure thing. I'm done with my day so will take care of it tomorrow! |
@thienlnam Testing well so far! Just wondering if the |
Not sure if this is within scope of this PR, but trying to save the |
@allroundexperts Bug: Open any report (without doing any of the Onyx.set steps), enter some value for the VAT Number default field returned from BE. Note several console errors: |
Bug: Go offline, update some field values and save, go back online. The field values disappear. (I assume this is related to the BE changes not being live). desktop-chrome-offline-2024-01-31_12.11.42.mp4 |
OpenReport should be returning the fields under report.reportFields, I'm not aware of anything being broken with it, but I also have some pusher updates changes for Report_SetFields
I think this because we're trying to add reportFields on a free plan for testing here - in theory, you won't be able to add these for free plans
You won't be able to change the formula, just the value so this works as expected |
I agree with @thienlnam about all these bugs. |
Added the correct QA steps @thienlnam. Please let me know if they look good enough. |
Yup - the QA steps look solid
Have you been able to check this bug? EDIT: Oh, I actually think this might be related to the free workspace thing. So going to merge without this since it doesn't appear to be a blocker |
✋ 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 production by https://github.com/marcaaron in version: 1.4.36-5 🚀
|
* Given a report field, check if the field is for the report title. | ||
*/ | ||
function isReportFieldOfTypeTitle(reportField: OnyxEntry<PolicyReportField>): boolean { | ||
return reportField?.type === 'formula' && reportField?.fieldID === CONST.REPORT_FIELD_TITLE_FIELD_ID; |
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.
Should Custom report name field necessarily be a formula?
We have an issue here #49077. The bug here is if we set the custom report name as some text string instead of a formula, backend returns the type of the title field as text
. Then this check fails and Title
field shows up in the report though it should not show up here as per this code
App/src/components/ReportActionItem/MoneyReportView.tsx
Lines 108 to 109 in 1354957
if (ReportUtils.isReportFieldOfTypeTitle(reportField)) { | |
return null; |
Can you please help here?
Details
This PR Integrates the policy report fields with the backend.
Fixed Issues
$ #34198
PROPOSAL: N/A
Tests
policyID
with thepolicyID
of thepolicy
the opened report is attached to:canUseReportFields
beta inPermissions.ts
file.Offline tests
Same as above
QA Steps
canUseReportFields
beta is enabled for the user.PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
Screen.Recording.2024-01-14.at.11.24.36.PM.mov
iOS: Native
Screen.Recording.2024-01-14.at.11.23.15.PM.mov
iOS: mWeb Safari
Screen.Recording.2024-01-14.at.10.57.37.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2024-01-14.at.10.51.35.PM.mov
MacOS: Desktop
Screen.Recording.2024-01-14.at.10.55.37.PM.mov