-
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
Display Smartscan errors #26155
Display Smartscan errors #26155
Conversation
@tylerkaraszewski 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] |
Adding screencaptures tomorrow |
Reviewer Checklist
Screenshots/VideosMobile Web - ChromeScreen.Recording.2023-09-01.at.3.27.29.PM.movMobile Web - SafariScreen.Recording.2023-09-01.at.3.24.45.PM.movDesktopScreen.Recording.2023-09-01.at.3.09.54.PM.moviOSScreen.Recording.2023-09-01.at.3.15.50.PM.movAndroidScreen.Recording.2023-09-01.at.3.29.42.PM.mov |
Screenshots added! |
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.
Code LGTM. Started testing but something is borked in my dev env with Expensiworks. I'll pause this for now as @tylerkaraszewski said he's going to continue testing this soon
Looks like @MariaHCD ran through this all last night (thanks!) and filled out the remainder of the checklist, so I'm just going to do some testing on one or two platforms and if that looks OK, merge. |
✋ 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/tylerkaraszewski in version: 1.3.62-0 🚀
|
* @returns {Boolean} | ||
*/ | ||
function hasMissingSmartscanFields(transaction) { | ||
return hasReceipt(transaction) && !isReceiptBeingScanned(transaction) && !areModifiedFieldsPopulated(transaction); |
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.
!isReceiptBeingScanned
involves OPEN
status as well as SCANFAILED
, SCANCOMPLETE
,
Should we show RBR for "OPEN" status?
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.
!isReceiptBeingScanned involves OPEN status as well as SCANFAILED, SCANCOMPLETE
Could you clarify this? isReceiptBeingScanned checks for SCANFAILED and SCANCOMPLETE
App/src/libs/TransactionUtils.js
Lines 254 to 257 in ebcc8d0
function isReceiptBeingScanned(transaction) { | |
return _.contains([CONST.IOU.RECEIPT_STATE.SCANREADY, CONST.IOU.RECEIPT_STATE.SCANNING], transaction.receipt.state); | |
} | |
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.
According to this function, !isReceiptBeingScanned
includes every status that isn't in CONST.IOU.RECEIPT_STATE.SCANREADY, CONST.IOU.RECEIPT_STATE.SCANNING]
.
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.
So hasMissingSmartscanFields
can return true if OPEN
status because isReceiptBeingScanned
is false
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 am not saying isReceiptBeingScanned
is wrong. It's correct 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.
What I am concerned is why should we show RBR when "OPEN" status?
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.
Ah, thanks for clarifying! So I think if we have any missing fields (even if the receipt is in the OPEN state), we would want to show the RBR to highlight any missing fields to the user
Coming from https://github.com/Expensify/Web-Expensify/pull/38582#issuecomment-1703609122 The RBR still shows even though the merchant, created and amount have been smartscanned. Tested on staging and it looks like the App/src/libs/TransactionUtils.js Lines 92 to 94 in ebcc8d0
Screen.Recording.2023-09-04.at.11.33.32.AM.movcc: @Gonals, is it possible the modified fields are not set when the scan completes? |
Yeah so for Expense report scans (not IOU), we use the transaction::update, which uses UpdateTranscation and we use the For IOUs we use the EditMoneyRequest and that always updates the modified fields |
Oh, thanks for pointing that out! What is the reason behind setting |
Thats how its was for years 😅 |
Hmmm. We should probably be consistent here. @mountiny, since you also touched this. Anything agains using |
@Gonals This is for all smartscans though right? I dont think the command is fully ocmpatible with everythign we need for oldDot smartscan |
Well, not quite, it'll be for smartscans for Free policies. Those are just Workspaces, so it should just be newdot stuff, I think. |
In any case, for now, I'll change the logic in the frontend to check all fields, as it is the safest option now that we are close to the deadline |
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.62-4 🚀
|
if (hasReceipt) { | ||
receiptURIs = ReceiptUtils.getThumbnailAndImageURIs(transaction.receipt.source, transaction.filename); | ||
hasErrors = TransactionUtils.hasMissingSmartscanFields(transaction); |
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.
We only needed to show the error if the user was able to edit this report. This later caused #27333
@@ -115,11 +116,12 @@ function ReportPreview(props) { | |||
const numberOfScanningReceipts = _.filter(transactionsWithReceipts, (transaction) => TransactionUtils.isReceiptBeingScanned(transaction)).length; | |||
const hasReceipts = transactionsWithReceipts.length > 0; | |||
const isScanning = hasReceipts && ReportUtils.areAllRequestsBeingSmartScanned(props.iouReportID, props.action); | |||
const hasErrors = hasReceipts && ReportUtils.hasMissingSmartscanFields(props.iouReportID); |
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.
This component hasn't subscribed to Onyx transactions collection, so if there is any update in related Onyx transactions collection, it won't cause re-render here. Causing this bug: #32256
@@ -86,8 +86,10 @@ function MoneyRequestView({report, parentReport, shouldShowHorizontalRule, trans | |||
|
|||
const hasReceipt = TransactionUtils.hasReceipt(transaction); | |||
let receiptURIs; | |||
let hasErrors = false; | |||
if (hasReceipt) { |
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.
@Gonals The hasReceipt
aslo return true
in case of manual request with attached receipt. So we want to show the error if the request is manual request with the attached receipt as well, right?
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 don't think we smartscan in those cases
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.
So rather than using hasReceipt
(line 90), we should use something like isScanRequest
(a way to differentiate manual requests with an attached receipt from a smartscan request), right?
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.
Because using hasReceipt
leads to the bug #34997
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.
That seems reasonable, yes.
I think this was added before we implemented the functionality to attach receipts to manual requests, so that wasn't a problem at the time.
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 don't think I would return anything new from the server (especially since isScanRequest
isn't something stored in the database). The proper way to know if a receipt was smartscanned is if the receipt has one of the CONST.IOU.RECEIPT_STATE
states. I think TransactionUtils.hasReceipt(transaction);
should be updated to look at that instead. Can you look into doing that?
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.
Also I am thinking that we maybe need two functions...
TransactionUtils.hasAttachment()
TransactionUtils.hasReceipt()
This would cover both cases and be more explicit for cases like this which are only meant to handle one case.
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.
to know if a receipt was smartscanned
Perhaps you misunderstood my point. I mean that we need to differentiate manual requests with an attached receipt from a smartscan request as we did in FE side:
App/src/libs/TransactionUtils.ts
Lines 51 to 52 in c675857
function isScanRequest(transaction: Transaction): boolean { | |
// This is used during the request creation flow before the transaction has been saved to the server |
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.
Hm, the backend already has several methods that are similar to that. I still don't know that I am following this discussion completely but from the way I see it, the FE code for isScanRequest()
needs to be refactored to account for the difference between a smartscan request and a manual request with attachment.
What does the backend have to do with it?
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.
The check for errors is done only when there is receipt and that caused #34997
cc @mountiny
Details
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/295256
PROPOSAL:
Tests
bwm.sh
+ -> Request Money -> Scan
and sending a random image. Make sure to choose a worskpace, as we'll be disabling Scan receipts for IOUs soon. A "Smartscanning" transaction should be created:bwm
to do its thing (you are waiting forSmartScan?receiptID=XXX
).Report preview:
And LHN (In the parent chat):
Offline tests
None
QA Steps
Testing receipts to smartscan is going to be hard, as you'll need to smartscan the receipt yourself... and I'm not sure this is doable. You can set yourself to QA smartscan following this instructions, but it may be hard to get the right receipt.
Alternatively, maybe you can just upload an image with instructions as a receipt? Or a receipt with no merchant visible! That should get the smartscanner to skip it!
Once that is done:
+ -> Request Money -> receipt
and sending a random image. Make sure to choose a worskpace, as we'll be disabling Scan receipts for IOUs soon. A "Smartscanning" transaction should be created.Report preview:
And LHN (In the parent chat):
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)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android