Skip to content
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

Receipt thumbnail should show the top of the receipt #35041

Merged
merged 38 commits into from
Apr 22, 2024

Conversation

dukenv0307
Copy link
Contributor

@dukenv0307 dukenv0307 commented Jan 24, 2024

Details

Fixed Issues

$ #34120
PROPOSAL: #34120 (comment)

Tests

  1. Create an IOU using receipt scanning
  2. Observe the thumbnail of the receipt
  3. Verify that Receipt thumbnail shows the top of the receipt
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Create an IOU using receipt scanning
  2. Observe the thumbnail of the receipt
  3. Verify that Receipt thumbnail shows the top of the receipt
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.mov
Android: mWeb Chrome android-mweb
iOS: Native
iOS: mWeb Safari
Screen.Recording.2024-01-30.at.14.56.56.mov
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov

@dragnoir
Copy link
Contributor

it's not working:

image

@cubuspl42
Copy link
Contributor

@dukenv0307 I can see that you're actively working on this! What's the current status of the PR? I think it would be great to prioritize this highly.

@dragnoir Thanks for volunteering to test this PR, but it's not needed or welcome. We'll ensure to test all image ratios.

@dukenv0307 dukenv0307 marked this pull request as ready for review January 30, 2024 09:34
@dukenv0307 dukenv0307 requested a review from a team as a code owner January 30, 2024 09:34
@melvin-bot melvin-bot bot requested review from cubuspl42 and removed request for a team January 30, 2024 09:34
Copy link

melvin-bot bot commented Jan 30, 2024

@cubuspl42 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]

@dukenv0307
Copy link
Contributor Author

@cubuspl42 The PR is ready for review. Have a question here, should we always set aspectRaito: 1 for wide image (width > height) or only set for the case of stack images (ReportActionItemImages).

@cubuspl42
Copy link
Contributor

@cubuspl42 The PR is ready for review. Have a question here, should we always set aspectRaito: 1 for wide image (width > height) or only set for the case of stack images (ReportActionItemImages).

Are you discussing something that affects user-observable behavior? If so, could you share screenshots of both options?

@dukenv0307
Copy link
Contributor Author

AspectRaito: 1 is added to fix this case #34120 (comment). So I want to ask about should we always set this for wide image or only set it in ReportPreivew.

  • AspectRaito: 1 for wide image
Screenshot 2024-01-30 at 16 56 13
  • AspectRaito: width / height
Screenshot 2024-01-30 at 16 56 43

@cubuspl42
Copy link
Contributor

It's a good question. I believe we should stop testing with moon images and figure out what might be the actual user stories here.

Let's consider this horizontal picture of a recipe (4:3):

walmart_receipe_horizontal

Also 16:9:

walmart_receipe_horizontal_wide

We shouldn't focus on anything wider. It's already focusing on corner cases.

(it's digitally edited, I didn't have a horizontal recipe image handy)

@cubuspl42
Copy link
Contributor

The linter is still complaining

@dragnoir
Copy link
Contributor

@cubuspl42 sorry about that. I was just wondering about the aspect ratio when there's no parent width/height specified. You're doing great with your work, and I'm keeping an eye on it to learn different ways to tackle this.

@cubuspl42
Copy link
Contributor

@dukenv0307 Ouch; conflicts

@dukenv0307
Copy link
Contributor Author

@cubuspl42 I tested and it only happens for scan requests with very long vertical images. The scan split doesn't happen that.

@cubuspl42
Copy link
Contributor

Okey, I'll re-test it with normal ratios! Real users will likely only upload photos from the camera, uncropped.

@cubuspl42
Copy link
Contributor

tested and it only happens for scan requests with very long vertical images. The scan split doesn't happen that.

This is not what I observe.

As I observe it, it appears that the backend returns a square thumbnail even when I upload a standard, 4:3 vertical image.

Image I used:

walmart_receipt_vertical

Thumbnail I got from the backend:

receipt_thumbnail

Images aligned on top of each other:

image

This is just basic, centered cropping.

@cubuspl42
Copy link
Contributor

cubuspl42 commented Apr 2, 2024

@Beamanator Would it be easy to adjust the backend, so it chooses the top portion of the image when generating the receipt thumbnail?

I'm also wondering if it's easy/possible to distinguish between the receipts and other images, and whether we're fine with aligning to the top of all user-uploaded images 🤔

@dukenv0307
Copy link
Contributor Author

dukenv0307 commented Apr 11, 2024

@Beamanator Please check this comment #35041 (comment) when you have a chance.

@Beamanator
Copy link
Contributor

Yikes i'm very sorry for the delay gents, I plan to get back to this ASAP this weekend or early next week - appologies!

@cubuspl42
Copy link
Contributor

@Beamanator Thanks!

Just as a reminder of the current state of this issue/PR:

We're implementing a feature originally discussed on Slack (it was called "bug", but this never worked "as expected", as far as I understand) to position the receipt thumbnails so the top of the image is presented, not the center.

We were holding on another issue for quite some time.

Currently, we are (mostly?) done with the frontend part of the task, but it seems that the backend behavior also needs some changes, as the thumbnail image comes pre-cropped to the frontend.

@Beamanator
Copy link
Contributor

Beamanator commented Apr 16, 2024

Ok I do have a theory on this one, it looks like a few months back (early feb) we merged this PR - https://github.com/Expensify/Web-PDFs/pull/560/files - which had the intent to fix #32649

We mayyyy have added an unnecessary center command which could be why the thumbnails are always centered on the image 🤔

I'll bring this ^ convo to the issue & pull in someone else

@Beamanator
Copy link
Contributor

@cubuspl42 will you please retest so we can hopefully get this merged today? 🙏

@cubuspl42
Copy link
Contributor

I have trouble testing this right now, the scan requests... disappear for me. Some backend hiccups?

@Beamanator
Copy link
Contributor

That definitely doesn't sound good @cubuspl42 ! Is it reproducible? Can you report a bug if it is?

@cubuspl42
Copy link
Contributor

I'm sorry for a lag, I'll retest this today.

@cubuspl42
Copy link
Contributor

I had really weird issues when testing this, but I believe that they were on the backend and unrelated to this PR.

Things look good now, no jump after the refresh!

receipt-retest-1-web-converted.mp4

@melvin-bot melvin-bot bot requested a review from Beamanator April 22, 2024 09:22
@Beamanator
Copy link
Contributor

Thanks for retesting everything @cubuspl42 ! Do you mind doing 1 more quick retest since @dukenv0307 just merged main? (since it had been a while) 🙏

@cubuspl42
Copy link
Contributor

@Beamanator I always merge main on my end before any testing

Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Beamanator Beamanator merged commit b1d25e4 into Expensify:main Apr 22, 2024
14 of 15 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@kbecciv
Copy link

kbecciv commented Apr 22, 2024

This PR is failing because of issue(#34120)

The issue is reproducible in: All environments

RPReplay_Final1713805433.MP4
2024-04-22.19.57.30.mov
top.of.the.receipt.mp4
1713802231792.A_Receipt_thumbnail_should_show_the_top_of_the_receipt.mp4
1713802231792.mWeb_Receipt_thumbnail_should_show_the_top_of_the_receipt.mp4

@cubuspl42
Copy link
Contributor

These are two different kinds of previews; in the videos, we can see that the ones we worked on (report action previews) do align to the top:

image

I recall that we discussed this other kind of previews at some point, but I can't find it now.

@dukenv0307

Do you have some more input here? Also, could you check if covering this second kind of previews is challenging technically? Does it also need backend changes?

@dukenv0307
Copy link
Contributor Author

dukenv0307 commented Apr 23, 2024

@cubuspl42 Do we mention that it doesn't work on Confirm page like the image below right? If yes the solution to fix this is simple and we can create a follow-up PR to fix this.

Screenshot 2024-04-23 at 15 53 33

cc @Beamanator

@cubuspl42
Copy link
Contributor

I think that that's what we're talking about. I think the users, mentally, don't consider various previews (submit expense previews vs. report action previews) to be really different, and they intuitively expect consistency.

Yes, please create a follow-up!

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 1.4.64-6 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants