Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.53k stars 2.88k forks source link

[HOLD for payment 2024-01-11] [$500] IOU- When replacing receipt and downloading it, previous receipt with new receipt name is downloaded #33363

Closed lanitochka17 closed 10 months ago

lanitochka17 commented 10 months ago

If you havenโ€™t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 1.4.14-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: Applause - Internal Team Slack conversation:

Action Performed:

  1. Navigate to IOU request details that has a receipt
  2. Click on the receipt
  3. Click 3-dot menu > Replace
  4. Upload another receipt
  5. After the upload is complete, download the receipt

Expected Result:

The latest receipt will be downloaded

Actual Result:

The previous receipt is downloaded, while the receipt file name is the name of the latest receipt On Android and iOS app, it downloads the previous receipt (file name is not affected/not relevant) after replacing the receipt

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/78819774/9832528f-9c30-42c3-a343-7921ac46c0dd

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0113378cba031fc595
  • Upwork Job ID: 1737485735446364160
  • Last Price Increase: 2023-12-20
  • Automatic offers:
    • shubham1206agra | Contributor | 28077368
Issue OwnerCurrent Issue Owner: @abdulrahuman5196
melvin-bot[bot] commented 10 months ago

Job added to Upwork: https://www.upwork.com/jobs/~0113378cba031fc595

melvin-bot[bot] commented 10 months ago

Triggered auto assignment to @alexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

melvin-bot[bot] commented 10 months ago

Bug0 Triage Checklist (Main S/O)

melvin-bot[bot] commented 10 months ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (External)

namhihi237 commented 10 months ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

The link source download does not update when replace the image

What is the root cause of that problem?

Currently, when the source changes we don't update in the threeDotsMenuItems.

What changes do you think we should make in order to solve the problem?

We should add the source into dependence

What alternative solutions did you explore? (Optional)

vikssevishnu commented 10 months ago

I am trying to access the issue details using the link "https://stackoverflow.com/c/expensify/questions/14418" but i am getting you do not have access. Can you help on it ?

melvin-bot[bot] commented 10 months ago

๐Ÿ“ฃ @vikssevishnu! ๐Ÿ“ฃ Hey, it seems we donโ€™t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
vikssevishnu commented 10 months ago

Contributor details Your Expensify account email: vishnu.vikas19@gmail.com Upwork Profile Link: https://www.upwork.com/freelancers/~01a59961216a1ee633?viewMode=1

melvin-bot[bot] commented 10 months ago

โœ… Contributor details stored successfully. Thank you for contributing to Expensify!

dukenv0307 commented 10 months ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

The previous receipt is downloaded, while the receipt file name is the name of the latest receipt On Android and iOS app, it downloads the previous receipt (file name is not affected/not relevant) after replacing the receipt

What is the root cause of that problem?

The receipt image preview now is a modal. So when it's closed, it's not unmounted. When we change the receipt, the props.source is changed but we don't update source state and we don't pass it as a dependency of threeDotsMenuItems

https://github.com/Expensify/App/blob/bd7629edb5f1ce62d849348bb4d259b0502c9526/src/components/AttachmentModal.js#L398

What changes do you think we should make in order to solve the problem?

We should create a useEffect to update source state when props.source is changed

useEffect(() => {
    setSource(props.source);
}, [props.source])

and add source as a dependency of this useMemo

https://github.com/Expensify/App/blob/bd7629edb5f1ce62d849348bb4d259b0502c9526/src/components/AttachmentModal.js#L398

What alternative solutions did you explore? (Optional)

We can use sourceForAttachmentView and add it as a dependency of threeDotsMenuItems useMemo

situchan commented 10 months ago

This is regression from #32647 which fixes #31105 (confirmed by reverting locally) It's still within regression period

shubham1206agra commented 10 months ago

In that case, @dukenv0307 please create a quick PR for this

Berndy commented 10 months ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

When a reciept attachement is replaced and then downloaded after, the old attachment will be downloaded.

What is the root cause of that problem?

source does not update when props.source updates.

The useMemo for the threeDotsMenuItems also does not depend on source, thus downloadAttachment will be called with the old source.

What changes do you think we should make in order to solve the problem?

We need to update source whenever props.source changes using a useEffect hook.

useEffect(() => {
    setSource(props.source);
}, [props.source])

We also need to add source to the useMemo dependencies for threeDotsMenuItems.

https://github.com/Expensify/App/blob/bd7629edb5f1ce62d849348bb4d259b0502c9526/src/components/AttachmentModal.js#L398

While i arrived at these conclusions by myself, so far they are the exact same as the proposal of @dukenv0307

However I had some more issues with this solution, as we now allow blob URLs as source until the attachment is done uploading. If we add the auth token when we are attempting to download a blob URL, the download will fail. I suggest we also add a check if source is a blob url before adding the encrypted auth token.

https://github.com/Expensify/App/blob/bd7629edb5f1ce62d849348bb4d259b0502c9526/src/components/AttachmentModal.js#L194-L205

What alternative solutions did you explore? (Optional)

We might want to check if props.source is set before calling setSource, but I am not 100% sure of the implications of this.

alexpensify commented 10 months ago

@abdulrahuman5196 should we close these GHs in favor of what @situchan mentioned above or move forward with the proposal review?

dukenv0307 commented 10 months ago

@shubham1206agra The PR ready for review.

alexpensify commented 10 months ago

Heads up, I will be offline from Friday, December 22, to Thursday, January 4, 2024. I will not be actively watching over this GitHub during that period. If anything urgent is needed here, please ask for help in the #expensify-open-source Slack Room-- thanks!

melvin-bot[bot] commented 10 months ago

Triggered auto assignment to @arosiclair, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] commented 10 months ago

๐Ÿ“ฃ @shubham1206agra ๐ŸŽ‰ An offer has been automatically sent to your Upwork account for the Contributor role ๐ŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review ๐Ÿง‘โ€๐Ÿ’ป Keep in mind: Code of Conduct | Contributing ๐Ÿ“–

abdulrahuman5196 commented 10 months ago

@abdulrahuman5196 should we close these GHs in favor of what @situchan mentioned above or move forward with the proposal review?

@alexpensify We can close this issue, given the PR was merged. This was a regression fix.

alexpensify commented 10 months ago

๐Ÿ‘๐Ÿผ - closing

melvin-bot[bot] commented 10 months ago

Reviewing label has been removed, please complete the "BugZero Checklist".

melvin-bot[bot] commented 10 months ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 1.4.21-4 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-01-11. :confetti_ball:

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

For reference, here are some details about the assignees on this issue:

melvin-bot[bot] commented 10 months ago

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

melvin-bot[bot] commented 10 months ago

โš ๏ธ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

alexpensify commented 10 months ago

@shubham1206agra - can you please identify if this PR triggered the deploy blocker or if there is another reason for this automation? Thanks!

shubham1206agra commented 10 months ago

Oh it's a false alert actually

alexpensify commented 10 months ago

@shubham1206agra - can you please share more context as to why the alert is wrong? It will be helpful to have it recorded here. Thanks!

shubham1206agra commented 10 months ago

@alexpensify https://github.com/Expensify/App/pull/33586 is the offending PR. Some contributor marked this by mistake as this issue is already deployed to production.

alexpensify commented 10 months ago

Thank you! I will continue the process to prepare for the payment date.

alexpensify commented 10 months ago

Based on the ๐Ÿ‘Ž๐Ÿผ here https://github.com/Expensify/App/issues/33363#issuecomment-1874209603 and the note here https://github.com/Expensify/App/issues/33363#issuecomment-1874348862, there is no payment action here since this issue was handled in other GH. I confirmed the Upwork job is closed too.