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

Search - Receipt thumbnail for invoice has plus icon when receipt cannot be added to invoice #48368

Merged
merged 6 commits into from
Sep 16, 2024

Conversation

FitseTLT
Copy link
Contributor

@FitseTLT FitseTLT commented Aug 30, 2024

Details

Fixed Issues

$ #47390
PROPOSAL: #47390 (comment)

Tests

Go to staging.new.expensify.com
Go to FAB > Send invoice.
Send an invoice to anyone.
Go to Search > Invoices
Verify that the list for the invoice you created in (2) doesn't have the plus icon but instead a receipt thumbnail icon

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  • 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(themeColors.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 a
Android: mWeb Chrome aw
iOS: Native image
iOS: mWeb Safari iw
MacOS: Chrome / Safari w
MacOS: Desktop d

@FitseTLT FitseTLT requested a review from a team as a code owner August 30, 2024 20:43
@melvin-bot melvin-bot bot requested a review from aimane-chnaif August 30, 2024 20:43
Copy link

melvin-bot bot commented Aug 30, 2024

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

@melvin-bot melvin-bot bot removed the request for review from a team August 30, 2024 20:43
@FitseTLT
Copy link
Contributor Author

FitseTLT commented Aug 30, 2024

@luacmartins Tagging you here because I have an important question regarding search.
Currently, the method we use to determine canModifyReceipt is via transactionItem.canDelete here

const canModifyReceipt = isViewAction && transactionItem.canDelete;

But canDelete is not sufficient to determine canModifyReceipt (which caused the current issue linked with this PR) instead the correct way to determine is implemented in this pr shortly it is :

  const parentReportAction = getIOUActionForReportID(transactionItem.reportID, transactionItem.transactionID);
    const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionItem.reportID ?? '-1'}`);
    const canUserPerformWriteAction = !!ReportUtils.canUserPerformWriteAction(report);
    const canEditReceipt = canUserPerformWriteAction && ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT);

    const canModifyReceipt = isViewAction && canEditReceipt;

But I have doubts. Doubts that the necessary data (parenetReportActions or linked reports) might not be available in local/onyx, assuming that's why props like canHold etc are returned in transactionItem.
Am I correct??
If I am, a properly calculated (based on the above logic or if you guys have functions to determine canModifyReceipt in BE) canModifyReceipt prop should be returned from BE.
WDYT Thx
Tagging also @aimane-chnaif @danieldoglas

@luacmartins
Copy link
Contributor

But I have doubts. Doubts that the necessary data (parenetReportActions or linked reports) might not be available in local/onyx, assuming that's why props like canHold etc are returned in transactionItem.
Am I correct??

They won't be available when viewing the results on the search page itself, but they should be once you click on the transaction and it opens in the RHP.

@FitseTLT
Copy link
Contributor Author

FitseTLT commented Sep 2, 2024

But I have doubts. Doubts that the necessary data (parenetReportActions or linked reports) might not be available in local/onyx, assuming that's why props like canHold etc are returned in transactionItem.
Am I correct??

They won't be available when viewing the results on the search page itself, but they should be once you click on the transaction and it opens in the RHP.

But the data I need canEditReceipt is when viewing the results.
So we need an additional canEditReceipt field on transactionItems returned from BE.
We need BE changes. @danieldoglas @luacmartins

@luacmartins
Copy link
Contributor

Hmm that would require additional data to be sent to the frontend, yes. The issue is that the new key wouldn't be live updated since it'd be a static key computed at the time the search was made and not a key evaluated based on report state/status. This would lead to potential out of sync values.

@Expensify/design tagging you to see if we can simplify the receipt icons (maybe standardize on one)

@dannymcclain
Copy link
Contributor

You know honestly, since that isn't a button/doesn't actually do anything, I personally think it would be fine to just use our receipt icon in that placeholder for everything.

image

I think originally I was imagining that placeholder to be actionable somehow, but I don't think we're going to do that, so it makes sense to me for this to just straight up be a placeholder. Then once you click into the item, it's clear whether you can add a receipt to it or it not and where to do that.

Of course curious for @Expensify/design's thoughts!

@luacmartins
Copy link
Contributor

I agree. Eager to hear more thoughts!

@dubielzyk-expensify
Copy link
Contributor

Yeah I agree with what @dannymcclain is saying here. Summed it up perfectly.

@shawnborton
Copy link
Contributor

I thought we already had an existing pattern though where we show a receipt with a slash through it for expenses that don't have any receipt present? Is that something we can reuse here too?
CleanShot 2024-09-04 at 12 14 33@2x

@FitseTLT
Copy link
Contributor Author

FitseTLT commented Sep 4, 2024

I thought we already had an existing pattern though where we show a receipt with a slash through it for expenses that don't have any receipt present? Is that something we can reuse here too? CleanShot 2024-09-04 at 12 14 33@2x

Don't think so @shawnborton, both the slashed and plus icons might mislead users we better use some general receipt thumbnail may be.

@shawnborton
Copy link
Contributor

Yeah, fair. Just noting that we do have an existing pattern we use when there is no receipt present and you cannot add a receipt.

@FitseTLT
Copy link
Contributor Author

FitseTLT commented Sep 4, 2024

Yeah, fair. Just noting that we do have an existing pattern we use when there is no receipt present and you cannot add a receipt.

Are u referring to this one?
image

@shawnborton
Copy link
Contributor

No, please see my screenshot above that I just posted today.

@FitseTLT
Copy link
Contributor Author

FitseTLT commented Sep 4, 2024

No, please see my screenshot above that I just posted today.

Yeah, but that's what I am assuming a bit confusing, misleading the user that they can't modify the receipt (b/c of the slashes). But whatever you guys think we should use let me know and let me proceed with the PR 👍
I vote for the receipt thumbnail @dannymcclain showed here

@shawnborton
Copy link
Contributor

misleading the user that they can't modify the receipt (b/c of the slashes)

Oh, I wasn't aware of that. In the expenses I am showing above, they are all in a non-editable state and thus I can't actually add a receipt to them. Am I missing something here though? Is there a case where we show that slash receipt icon but we actually do allow you to upload a receipt?

@FitseTLT
Copy link
Contributor Author

FitseTLT commented Sep 4, 2024

Is there a case where we show that slash receipt icon but we actually do allow you to upload a receipt?

No. But what I am saying is now we show the slashed one for non-editable and the plus for the editable but in this pr we are going to stop showing different receipt icons based on receipt modifiability so for me it doesn't make sense to use either of the two since they already have separate meanings to the user.

@shawnborton
Copy link
Contributor

Hmm I am not following. But I feel like we should do the following:

  • If there is no receipt but a receipt can be added, use the receipt with a plus icon
  • if there is no receipt and a receipt can not be added, use the receipt with a slash icon

Is there any reason why we can't do that?

@FitseTLT
Copy link
Contributor Author

FitseTLT commented Sep 4, 2024

Hmm I am not following. But I feel like we should do the following:

  • If there is no receipt but a receipt can be added, use the receipt with a plus icon
  • if there is no receipt and a receipt can not be added, use the receipt with a slash icon

Is there any reason why we can't do that?

Aha you have missed this discussion.

@dannymcclain
Copy link
Contributor

@shawnborton I totally see what you're saying, and that is indeed how we originally designed it. I'm just questioning how helpful that actually is since if you want to add a receipt you have to open the expense either way.

And since you have to open the expense regardless, I feel like the actual expense view does a great job communicating whether or not you can add a receipt.

If you can add a receipt, you see this:
CleanShot 2024-09-04 at 09 01 38@2x

If you can't add a receipt, you see this:
CleanShot 2024-09-04 at 09 02 27@2x

So basically my thought is we can simplify the search row receipt placeholder and let the expense view do the heavy lifting here. I think that's what I would prefer to do, but I am but one man, a tiny speck of life on a great rock hurtling through space and time. ✨

@shawnborton
Copy link
Contributor

Hahaha I'm also made out of space dust. I guess my thinking is that if we use a generic receipt icon as a placeholder for everything, it kinda gives the vibe that it's a placeholder for an actual receipt? I don't feel too strongly though, but I think I do lean towards using case-specific icons if we can.

@shawnborton
Copy link
Contributor

Maybe we just need to call up the judge (yo @dubielzyk-expensify !!) and see what the verdict is.

@dubielzyk-expensify
Copy link
Contributor

After this discussion I think I've turned around, but I don't really love the receipt with a slash through. It feels a bit harsh and error-y. I wonder if we could do this instead to arrive somewhere in the medium:

image

I don't feel super strongly as I don't think it needs to be super obvious in any angle. If not the one above, then I vote for what @shawnborton is saying

@dannymcclain
Copy link
Contributor

I'm down to go the direction Jon suggested (and I think I do like his proposed update to the icon), but again, I don't really see the value in trying to communicate whether you can or can't add a receipt with this icon. It's not a button, so the receipt plus doesn't super duper make sense to me the more I think about it.

But I am totally happy to leave it alone—I've shared my two cents!

I do kinda worry that we're not solving the problem raised in this issue though—you still can't add a receipt to an invoice and we'll still be showing the receipt plus icon, right? So how do we fix that?

@FitseTLT
Copy link
Contributor Author

FitseTLT commented Sep 5, 2024

I'm down to go the direction Jon suggested (and I think I do like his proposed update to the icon), but again, I don't really see the value in trying to communicate whether you can or can't add a receipt with this icon. It's not a button, so the receipt plus doesn't super duper make sense to me the more I think about it.

But I am totally happy to leave it alone—I've shared my two cents!

I do kinda worry that we're not solving the problem raised in this issue though—you still can't add a receipt to an invoice and we'll still be showing the receipt plus icon, right? So how do we fix that?

@dannymcclain Yes. In this pr we were aiming to fix the receipt icon for invoices but @luacmartins raised a syncing issue that might arise regarding the data returned from BE here So wanted to know your opinion on using a single receipt icon for both cases instead of two separate plus and slashed icons. Therefore, If you agree with this please you need to give me the receipt thumbnail icon to use for both cases (can and cannot add receipt cases)

@shawnborton
Copy link
Contributor

Given that we already have a pattern that exists for showing a certain thumbnail icon for an expense that cannot have a receipt added, I feel like we should just reuse the existing pattern that we have today and then revisit the pattern as a whole as a separate initiative. I think some good points were made in this PR but I don't think we've really landed in one place or the other with strong conviction, so I would opt to just keep the status quo and revisit later on.

That means just using the receipt with slash for expense rows for Invoices. Could we just do that to start?

@dannymcclain
Copy link
Contributor

I don't think we've really landed in one place or the other with strong conviction, so I would opt to just keep the status quo and revisit later on.
That means just using the receipt with slash for expense rows for Invoices. Could we just do that to start?

Great point. Happy to go with this.

@luacmartins
Copy link
Contributor

Yes, that's right! Thanks for summarizing it :)

@FitseTLT
Copy link
Contributor Author

@dannymcclain Is the receipt thumbnail icon you showed #48368 (comment) already available in the app or it is a new icon you are going to give me?

@dannymcclain
Copy link
Contributor

It's already in the repo—it's our standard receipt icon.

App/assets/images/receipt.svg

@FitseTLT
Copy link
Contributor Author

It's already in the repo—it's our standard receipt icon.

App/assets/images/receipt.svg

Thanks. It looks like this, I want a confirmation @dannymcclain

2024-09-10.23-59-42.mp4

@dannymcclain
Copy link
Contributor

Looks right to me!

@aimane-chnaif
Copy link
Contributor

@FitseTLT is this ready for review?

@FitseTLT
Copy link
Contributor Author

@FitseTLT is this ready for review?

Will upload snapshots shortly 👍

@FitseTLT
Copy link
Contributor Author

@aimane-chnaif You can proceed.

@aimane-chnaif
Copy link
Contributor

aimane-chnaif commented Sep 12, 2024

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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
    • 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native image
Android: mWeb Chrome
iOS: Native

ios

iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov
MacOS: Desktop

@melvin-bot melvin-bot bot requested a review from danieldoglas September 12, 2024 19:43
luacmartins
luacmartins previously approved these changes Sep 12, 2024
Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

LGTM

@FitseTLT
Copy link
Contributor Author

@luacmartins I have removed receipt plus icon on the latest commit but not receipt slash as we also use it in PDFThumbnailError and also bumping you or @danieldoglas for merge

@FitseTLT
Copy link
Contributor Author

From the thump-up response I think we all agree not to delete the icon so I have reverted the last commit. Let's get it merged @luacmartins or @danieldoglas

@FitseTLT
Copy link
Contributor Author

@danieldoglas It's ready for your final 👁️ . Thx.

Copy link
Contributor

@danieldoglas danieldoglas left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@danieldoglas danieldoglas merged commit 025a630 into Expensify:main Sep 16, 2024
16 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.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/danieldoglas in version: 9.0.36-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.0.36-2 🚀

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.

8 participants