Fix new individual invoice after one is paid as a business#54138
Fix new individual invoice after one is paid as a business#54138puneetlath merged 23 commits intomainfrom
Conversation
|
Hi, this is ready for review now. The lint check is failing due to new rules about defaulting IDs, but I didn't add any of that. It already exists on main in some of the files I touched. I tried fixing it, but it creates a cascading effect of more and more files to fix and I don't want to get stuck in that rabbit hole. Let's please get this issue fixed, then fix the lint check separately since that will be a huge PR. |
|
@allgandalf 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] |
|
Can you fix the failing |
|
This has conflicts 😞 |
Please see this comment. I resolved the merge conflicts. |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-12-25.at.8.45.12.PM.movAndroid: mWeb ChromeScreen.Recording.2024-12-25.at.8.48.45.PM.moviOS: NativeScreen.Recording.2024-12-25.at.7.58.17.PM.moviOS: mWeb SafariScreen.Recording.2024-12-25.at.7.59.50.PM.movMacOS: Chrome / SafariScreen.Recording.2024-12-25.at.7.51.40.PM.movMacOS: DesktopScreen.Recording.2024-12-25.at.7.55.27.PM.mov |
allgandalf
left a comment
There was a problem hiding this comment.
LGTM overall, only one comment I will complete the checklist either ways
| Log.warn('getReceiverType called with no receiverParticipant'); | ||
| return CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL; | ||
| } | ||
| if ('type' in receiverParticipant && receiverParticipant.type) { |
There was a problem hiding this comment.
I guess optional chaining was troubling here 😆
There was a problem hiding this comment.
Yes the type narrowing seems to be necessary because the receiverParticipant is a combination of two types.
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| private_isArchived: unknown; | ||
| state: unknown; | ||
| welcomeMessage: unknown; |
There was a problem hiding this comment.
I think this comment is strange. The whole thing is pretty confusing. It's just listing all the fields in the report and asserting that they're in the report type. I don't find any value in that because it's totally circular.
I found the related issue, and the goal there is to move client only keys out of the report type. So now I understand the purpose. It also doesn't really make sense to limit that to the OpenApp call, I think OpenReport is also a valid way to tell which keys come from the server. I checked the response and I see that welcomeMessage is returned but state is not, so I'll remove state.
Thanks for pointing this out.
|
and we have conflicts... |
|
Don't think those conflicts are any major thing, so i will continue with uploading the videos |
allgandalf
left a comment
There was a problem hiding this comment.
LGTM! Tests well, lets fix the conflicts and we can merge 🚀
|
@puneetlath 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] |
|
Please ignore the failing es lint @puneetlath , have a look at this comment |
|
@puneetlath looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
Merged even though ESLint was failing based on this reasoning. |
|
✋ 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/puneetlath in version: 9.0.80-1 🚀
|
|
@neil-marcellini This PR is failing with issue #54723 https://platform.utest.com/services/links/v1/internal/55801408?.mp4 |
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.0.80-6 🚀
|
| if ('type' in receiverParticipant && receiverParticipant.type) { | ||
| return receiverParticipant.type; | ||
| } | ||
| if ('policyID' in receiverParticipant && receiverParticipant.policyID) { |
There was a problem hiding this comment.
report.policyID can be _FAKE_ which is a DM. In that case, the type should be INDIVIDUAL.
See the bug mentioned in this proposal: #70004 (comment).

Explanation of Change
The main change is
ReportUtils.getInvoiceChatByParticipants, which now must have areceiverTypepassed. That fixes the root cause of the linked issue, because now this function will only get a report with the proper receiver type. Previously, after one invoice was sent to and individual and then paid as a business, sending another invoice to the individual would incorrectly try to use the converted invoice chat, which caused a backend error. Now the function will not find an individual invoice chat, and correctly create a new one. I added a unit test in ReportUtilsTest using data from manual testing which is stored intests/data/Invoice.ts. That data included some fields which were not part of the type definitions, so I added those and had to adjust types in a few other places.Fixed Issues
$ #53019
$ https://github.com/Expensify/Expensify/issues/401789
PROPOSAL: #53019 (comment)
Tests
Offline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.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 and/or tagged@Expensify/designso 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
I only tested on Mac Chrome because the changes are to one function that is platform independent.
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
2024-12-17_10-29-13.mp4
MacOS: Desktop