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

Animate payment icon in money request preview #54490

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

abzokhattab
Copy link
Contributor

@abzokhattab abzokhattab commented Dec 24, 2024

Explanation of Change

Fixed Issues

$ #53474
PROPOSAL: #53474 (comment)

Tests

Scenario one:

  1. Create a new workspace
  2. Submit an expense
  3. Click Pay elsewhere in the report preview
  4. Validate that the payment animation is working as expected
  5. Submit another expense
  6. Click on the report preview
  7. click on pay elsewhere in the report header
  8. Validate that the payment animation is working as expected

Scenario two:

  1. Create a new workspace
  2. Click on more features and enable workflows
  3. Click on the Workflows tab, then enable Add approvals
  4. Go to workspace chat and and Submit an expense
  5. in the report preview, Click on Approve
  6. Validate that the approval animation is working as expected.
  7. Click Pay elsewhere in the report preview
  8. Validate that the payment animation is working as expected
  9. Submit another expense
  10. Click on the report preview
  11. click on Approve in the report header
  12. Validate that the approval animation is working as expected.
  13. Click Pay elsewhere in the report header
  14. Validate that the payment animation is working as expected

Offline tests

Same as tests

QA Steps

Same as tests

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 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 used JaimeGPT to get English > Spanish translation. I then posted it 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 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 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.ts 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 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.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • 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
Untitled.mov
Android: mWeb Chrome
Screen.Recording.2024-12-24.at.04.31.10.mov
iOS: Native
Screen.Recording.2024-12-24.at.04.42.20.mov
iOS: mWeb Safari
Screen.Recording.2024-12-24.at.04.24.16.mov
MacOS: Chrome / Safari
Screen.Recording.2024-12-24.at.03.35.03.mov
Screen.Recording.2024-12-24.at.03.55.24.mov
MacOS: Desktop
Screen.Recording.2024-12-24.at.05.03.43.mov

@abzokhattab abzokhattab marked this pull request as ready for review December 24, 2024 03:08
@abzokhattab abzokhattab requested a review from a team as a code owner December 24, 2024 03:08
@melvin-bot melvin-bot bot requested review from ntdiary and removed request for a team December 24, 2024 03:08
Copy link

melvin-bot bot commented Dec 24, 2024

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

@abzokhattab
Copy link
Contributor Author

abzokhattab commented Dec 24, 2024

Some points i want share here:

  1. I removed the animation hook introduced in the previous commits. Upon closer inspection, I found that this hook was unnecessary, as it was tightly coupled to the settlement button. Instead, it’s better to declare all animation-related props directly within the animated settlement button component.
  2. I changed the animation to a fade-out effect, as requested in this comment .
  3. Since the animation has been updated to a fade-out effect, the canIOUBePaid prop inside the animated settlement button is no longer necessary and has been removed.
  4. I created a new usePaymentAnimations hook to manage shared useState values used in both the report header and report preview components. This approach ensures that only the start and end animation state values are exposed to these components, allowing them to use these states as needed.
  5. I removed the onLayout function inside the animated settlement button that made the "Payment Complete" or "Approved" button match the size of the "Pay" button. This constraint caused issues when handling duplicate reports, where the "Approved" text appeared cut off and didn’t fit well inside the button. Removing this constraint resolves that issue.
  6. The pay/approve buttons doesnt show up in the report header when using IOS native, is this a known bug?
Screenshot 2024-12-24 at 04 26 11

Let me know if you have any questions or suggestions!

@ntdiary
Copy link
Contributor

ntdiary commented Dec 24, 2024

@abzokhattab, could you please provide an animation video, and cc @Expensify/design to confirm it? :D

@ntdiary
Copy link
Contributor

ntdiary commented Dec 26, 2024

@abzokhattab, could you please provide an animation video, and cc @Expensify/design to confirm it? :D

Ignore that silly comment. 😅


@dubielzyk-expensify, when you have time, could you please help review the animation in the video from the author check list?

@ntdiary
Copy link
Contributor

ntdiary commented Dec 27, 2024

Sorry for the delay, I expect to have time to review the code over the weekend, and will try to complete the review early next week.

@abzokhattab
Copy link
Contributor Author

Sorry for the delay, yes i attached the animation in the PR let me know if you need other videos

@ntdiary
Copy link
Contributor

ntdiary commented Dec 30, 2024

bug 1: The margin above the button has been removed (ReportPreview), and I don't think this was an intended change.

this PR prod
image image

bug 2: The button container is missing the flex style, which might also be the reason why the button isn't displaying in the header on iOS native.

this PR prod
image image

another question: perhaps the brief loading replacement is causing the button flickering 🤔

test-header.mp4

BTW, @Expensify/design, this is in comparison to the prod animation (report preview):

this PR prod
test-wide-screen.mp4
prod-wide-screen.mp4

@shawnborton
Copy link
Contributor

Good catches, we should make sure those are fixed before this is merged.

@dubielzyk-expensify
Copy link
Contributor

dubielzyk-expensify commented Jan 6, 2025

Agree with all the bugs posted above 👍 A few notes as well:

The recording on iOS native in the OG post feel perfect to me. That should be what we're aiming for. The last video on this comment labeled This PR has the checkmarks appearing on the button and preview card at different times and I think we should make sure these match.

I don't think the approved button should have the checkmark in the button. Feels like we should either not use a checkmark there or use the thumbs up there as well (keen to hear @Expensify/design 's thoughts here. I wonder if we should actually just say "Payment complete" and "Approved" without the icon in the button to avoid double icons?):

CleanShot 2025-01-06 at 15 17 28@2x

Also there's a weird bug on the video MacOS Desktop video where it goes from paid -> approved -> paid again?

CleanShot.2025-01-06.at.15.19.29.mp4

@lakchote lakchote self-requested a review January 6, 2025 10:03
@dannymcclain
Copy link
Contributor

I don't think the approved button should have the checkmark in the button. Feels like we should either not use a checkmark there or use the thumbs up there as well (keen to hear @Expensify/design 's thoughts here. I wonder if we should actually just say "Payment complete" and "Approved" without the icon in the button to avoid double icons?):

Definitely agree that approved should use the thumbs up icon. But I'm not against not including the icon here since the preview gets it. I think in the report header it would be nice to keep the icon in the button, so I'm ALSO not against leaving them and just having the double-icon for a brief moment before the button disappears. But either way, let's make sure the icon matches the action (pay = checkmark, approve = thumbs up).

@dubielzyk-expensify
Copy link
Contributor

Fair points. Let's leave them in the button for now and make all the other changes, then see how it feels 👍

@lakchote
Copy link
Contributor

lakchote commented Jan 9, 2025

Any updates @abzokhattab?

@ntdiary
Copy link
Contributor

ntdiary commented Feb 5, 2025

I’ve been repeatedly testing approval and payment many many times this week, trying to address the flickering issue, and have made some progress. Also, I’ve fixed several small bugs on this PR locally. I expect to need one more workday to test and refine my suggestions.
Finally, I apologize for the delay in the update, as I really don’t want to push the flickering issue to production. (since it doesn’t exist in production yet)

@lakchote
Copy link
Contributor

lakchote commented Feb 5, 2025

I’ve been repeatedly testing approval and payment many many times this week, trying to address the flickering issue, and have made some progress. Also, I’ve fixed several small bugs on this PR locally. I expect to need one more workday to test and refine my suggestions. Finally, I apologize for the delay in the update, as I really don’t want to push the flickering issue to production. (since it doesn’t exist in production yet)

Thanks for the update. I agree about the flickering issue (we don't want it). Let's take a bit more time but make things right!

@ntdiary
Copy link
Contributor

ntdiary commented Feb 7, 2025

@ntdiary There was a race condition causing the “Payment Complete” or “Approved” text to sometimes reappear after the button faded out, so I used local state to prevent that.

Please let me know if you have any suggestions to make it even better, @ntdiary.

@abzokhattab, It seems the current PR doesn’t have this local state, so the flickering could still occur? Could you please push that change to let me test? Additionally, I made a few attempts on your branch, please feel free to checkout them, the main changes include:

  1. adjust the margin for confirm type modal on larger screen.
  2. use !isReportApproved to remove duplicate button (when there are multiple approvers and the last one hasn't approved yet, this button should not be removed).
  3. use keyframe animation to simplify the logic and make the transition smoother.

my commits: https://github.com/ntdiary/expensify-app/commits/keyframe/

Here are some test videos:

case / env production current PR keyframe animation
preview (without duplicate)
prod-preview-1.mov
pr-preview-1.mov
op-preview-1.mov
preview (with duplicate)
prod-preview-d.mp4
pr-preview-d.mov
op-preview-d.mov
header (without duplicate)
prod-header-1.mp4
pr-header-1.mov
op-header-1.mov
header (with duplicate)
prod-header-d.mp4
pr-header-d.mov
op-header-d.mov

@abzokhattab
Copy link
Contributor Author

abzokhattab commented Feb 10, 2025

I like the new approach using Keyframe... regarding the local state—I removed it because of an issue where "Payment Complete" or "Approved" were no longer occurring. So, in my latest modifications, I removed it from my previous approach to clean up the code: GitHub Commit.
However, this is not the root cause of the flickering issue

Additionally, there's another issue (which I also see in the main branch) where, when the user clicks "Submit," it switches to "Approve," then back to "Submit," and then "Approve" again.

@abzokhattab
Copy link
Contributor Author

but for now should we go with the new approach using Keyframe ?

@ntdiary
Copy link
Contributor

ntdiary commented Feb 11, 2025

Additionally, there's another issue (which I also see in the main branch) where, when the user clicks "Submit," it switches to "Approve," then back to "Submit," and then "Approve" again.

This is a separate issue (#53263), RCA is the GetMissingOnyxMessages API returns incorrect data.

but for now should we go with the new approach using Keyframe ?

As for the keyframe solution, I personally prefer this approach and am still trying to see if we can get rid of the direct call to setTimeout.

@abzokhattab, please feel free to test and optimize it locally. If it works well and you think it's okay, then push it and let us review it again. :)

@abzokhattab
Copy link
Contributor Author

abzokhattab commented Feb 11, 2025

  • I reviewed it once more and found an issue in the design. The "Approved" and "Payment is Complete" states appear too briefly.
  • Using keyframe, I am unable to adjust the timing between the "Approve" and "Approved" states, or between "Pay" and "Payment is Complete."
  • also, I noticed that the loading bar is not displayed as requested in the design.
  1. @shawnborton @dubielzyk-expensify @dannymcclain, please check the video in this comment and the screenshots provided by @ntdiary here . If the keyframe animation looks good to the animation .
  2. If we need to extend the duration of the "Approved" or "Payment is Complete" states, how can we do that? I am unable to adjust it because the keyframe script only includes the fade-out animation duration
  3. I also pushed the keyframe changes to save time, so the review can start sooner if they look good to the design team, else i will revert this commit if we conclude on the existing implementation
Screen.Recording.2025-02-11.at.21.25.31.mov

@shawnborton
Copy link
Contributor

I'm not too familiar with how keyframe works, so let's get the opinion of an engineer on whether or not we should use it.

@ntdiary
Copy link
Contributor

ntdiary commented Feb 12, 2025

also, I noticed that the loading bar is not displayed as requested in the design.

This is something I intentionally removed, based on the following considerations:

  1. The comment states loader in between if we need it, so I feel loader is optional, not mandatory.
  2. In the previous implementation, the loading wasn't connected to any API or Onyx data, it simply extended the animation duration without any other practical significance.
  3. If there's a real need for loading in the future, implementing it won't be difficult.
  • I reviewed it once more and found an issue in the design. The "Approved" and "Payment is Complete" states appear too briefly.
  • Using keyframe, I am unable to adjust the timing between the "Approve" and "Approved" states, or between "Pay" and "Payment is Complete."

This is actually controlled by the canShow timeout. For example, if I adjust it to 1000 (i.e., CONST.ANIMATION_PAID_BUTTON_HIDE_DELAY), the effect in the release version will be like this:
cc @abzokhattab

delay-1000.mov

@dannymcclain
Copy link
Contributor

I'm not too familiar with how keyframe works, so let's get the opinion of an engineer on whether or not we should use it.

Same here. I'm mostly concerned with smoothness and performance. I don't know that I have a strong opinion about the details of how we accomplish that.

@abzokhattab
Copy link
Contributor Author

This is actually controlled by the canShow timeout. For example, if I adjust it to 1000 (i.e., CONST.ANIMATION_PAID_BUTTON_HIDE_DELAY), the effect in the release version will be like this:

correct i tried yesterday but maybe the device didnt render ... good i think we are ready now .. i disabled the container shrinking when clicking on the approval ... can you please review the changes @ntdiary

@ntdiary
Copy link
Contributor

ntdiary commented Feb 12, 2025

Prevent the container height shrinking on approval

@abzokhattab, could you please share a video of this problem? It would be better if there are stable reproduction steps. BTW, I just noticed a height warning, maybe we need to figure out a way to address it. And If it's not solvable or too complex, we might have to revert to the previous containerStyles approach (just for container View), will provide an update tomorrow. :)

image

@abzokhattab
Copy link
Contributor Author

abzokhattab commented Feb 12, 2025

Prevent the container height shrinking on approval

for this issue i thought keyframe would act the same way as in the other way ... however after trying it for couple of times it seems that the height doesnt change so i removed this change in the recent commit

other than that, there is an issue in the DecisionModal where the margin is cut off because of this commit

Screenshot 2025-02-12 at 19 33 10

so i reverted this commit, let me know if u think otherwise @ntdiary

here is the result after the revert:
image

With this i think we can go ahead with the review.

@shawnborton
Copy link
Contributor

Good catch, I'm not sure why the modal needs to be modified for this PR.

@abzokhattab
Copy link
Contributor Author

we modified it to address this comment #54490 (comment) #54490 (comment)

@shawnborton
Copy link
Contributor

Hmm but the comment was just about the button size, not the margins on the modal itself right?

@shawnborton
Copy link
Contributor

Either way, we need to fix it.

@abzokhattab
Copy link
Contributor Author

Yes i reverted it, but it was a part of the alignment change #54490 (comment)

@ntdiary
Copy link
Contributor

ntdiary commented Feb 13, 2025

@abzokhattab, ESLint check failed.

@abzokhattab
Copy link
Contributor Author

done

Copy link
Contributor

@ntdiary ntdiary left a comment

Choose a reason for hiding this comment

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

@abzokhattab, unfortunately, I’m still seeing the height warning, so I made some changes to AnimatedSettlementButton, please feel free to test it locally first, and if everything works fine, you can replace it. I’ll make the full test videos and fill out the check list tomorrow.

Also, here are my latest test videos, I think it’s much smoother than before. :)

position/case normal duplicate
header
header-normal.mov
header-duplicate.mov
preview
preview-normal.mov
preview-duplicate.mov

src/CONST.ts Outdated Show resolved Hide resolved
src/CONST.ts Show resolved Hide resolved
src/CONST.ts Outdated Show resolved Hide resolved
@abzokhattab
Copy link
Contributor Author

LGTM

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