Skip to content

[Due for payment 2025-11-26] [$250] Android - Scan receipt- Unable to download a receipt in the confirmation page #74685

Closed

Description

@jponikarchuk

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: v9.2.47-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/folder/13176933/test-cases/41237700
Email or phone of affected tester (no customers): testpayment935@gmail.com
Issue reported by: Applause Internal Team
Device used: Samsung s10/ Android 12
App Component: Money Requests

Action Performed:

  1. Open Hybrid App
  2. Navigate to the workspace chat as the employee
  3. Select the option to Submit expense > Scan receipt
  4. Select the option to upload a receipt
  5. Upload a receipt file
  6. Click on the receipt to open the image to see it fully
  7. From three dot menu choose Download options

Expected Result:

Both the download and replace options works well

Actual Result:

Unable to download a receipt error shown

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021987936396746461489
  • Upwork Job ID: 1987936396746461489
  • Last Price Increase: 2025-11-10
Issue OwnerCurrent Issue Owner: @Christinadobrzyn

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Nov 10, 2025
  2. melvin-bot commented on Nov 10, 2025

    @melvin-bot

    Triggered auto assignment to @Christinadobrzyn (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. nkdengineer commented on Nov 10, 2025

    @nkdengineer
    Contributor

    Proposal

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

    Unable to download a receipt error shown

    What is the root cause of that problem?

    The local source can contain URL-encoded characters

    Image

    And we pass this soure here without decoded the URI, the error appears because we can't find the file with this URI.

    attachmentPath ?? '',

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

    We should decode the URI first

    let attachmentPath = isLocalFile ? decodeURIComponent(url ?? '') : undefined;
    

    let attachmentPath = isLocalFile ? url : undefined;

    What alternative solutions did you explore? (Optional)

    We can hide the download option for the local file here even if draftTransactionID eixsts

    if ((!isOffline && allowDownload && !isLocalSource) || !!draftTransactionID) {

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  4. TaduJR commented on Nov 10, 2025

    @TaduJR
    Contributor

    Proposal

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

    On Android, when uploading a scanned receipt with spaces in the filename, clicking "Download" from the three-dot menu shows an "Unable to download a receipt" error.

    What is the root cause of that problem?

    The local file URI contains URL-encoded characters (e.g., %20 for spaces), but this encoded URI is passed directly to the filesystem API without decoding.

    The file URI is URL-encoded:

    file:///data/cache/receipt%202024-10-10%2006_43_12.pdf
    

    But the actual filename has spaces:

    receipt 2024-10-10 06_43_12.pdf
    

    At line 49, the URL-encoded URI is assigned without decoding:

    let attachmentPath = isLocalFile ? url : undefined;

    let attachmentPath = isLocalFile ? url : undefined;

    This encoded path is then passed to copyToMediaStore at line 83:

    return RNFetchBlob.MediaCollection.copyToMediaStore(
    {
    name: attachmentName,
    parentFolder: 'Expensify',
    mimeType: null,
    },
    'Download',
    attachmentPath ?? '',
    );

    The API interprets %20 as literal characters instead of an encoded space, resulting in "No such file" error.

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

    Decode the URI at line 49:

    let attachmentPath = isLocalFile ? url : undefined;

    Before:

    let attachmentPath = isLocalFile ? url : undefined;

    After:

    let attachmentPath = isLocalFile ? decodeURI(url) : undefined;

    This decodes URL-encoded characters (%20 → space) so the path matches the actual filename on disk.

    Why decodeURI() instead of decodeURIComponent():

    Both functions decode URL-encoded characters, but they handle reserved characters differently:

    • decodeURI(): Designed for complete URIs. Decodes %20, %23, etc., but preserves / (won't decode %2F)
    • decodeURIComponent(): Designed for URI components. Decodes everything including %2F → /

    Advantages of decodeURI() for file URIs:

    1. Preserves path structure - Won't decode %2F to /, preventing potential directory traversal issues

      • Example: If a path contains folder%2Ffile, decodeURIComponent() would incorrectly decode it to folder/file, changing the directory structure
      • decodeURI() keeps it as folder%2Ffile, matching the actual filename
    2. Semantically correct - Designed for complete URIs (like file paths), not URI components (like query parameters)

      • Using the right tool for the job makes code more maintainable and predictable
    3. Safer for edge cases - While Android sanitizes / in filenames, defensive coding prevents issues if this changes or in unexpected scenarios

    4. Matches existing codebase pattern - Consistency improves code quality:

    // Decode URI if it's URL-encoded (handles special characters in filenames)
    let decodedPath = path;
    try {
    decodedPath = decodeURI(path);
    } catch (e) {
    // If decoding fails, use the original path

    1. Better readability - Future developers will immediately understand we're decoding a complete URI, not a URI component
  5. Christinadobrzyn commented on Nov 10, 2025

    @Christinadobrzyn
    Contributor

    I'm not able to reproduce this in Browserstack as I don't have access to any files for testing. Since there are proposals of this I'll add External to continue.

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Nov 10, 2025
  7. melvin-bot commented on Nov 10, 2025

    @melvin-bot
  8. changed the title [-]Android - Scan receipt- Unable to download a receipt in the confirmation page[/-] [+][$250] Android - Scan receipt- Unable to download a receipt in the confirmation page[/+] on Nov 10, 2025
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Nov 10, 2025
  10. melvin-bot commented on Nov 10, 2025

    @melvin-bot

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

  11. TaduJR commented on Nov 10, 2025

    @TaduJR
    Contributor

    Hello @Christinadobrzyn

    Please use PDF file that have spaces on the filename.

    You can reliably reproduce after that

    Thank you

  12. 21 remaining items

  13. melvin-bot commented on Nov 19, 2025

    @melvin-bot

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

    If no regressions arise, payment will be issued on 2025-11-26. 🎊

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

  14. melvin-bot commented on Nov 19, 2025

    @melvin-bot

    @mananjadhav @Christinadobrzyn The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  15. Christinadobrzyn commented on Nov 19, 2025

    @Christinadobrzyn
    Contributor

    @mananjadhav do we need a regression test?

  16. mananjadhav commented on Nov 19, 2025

    @mananjadhav
    Collaborator

    @Christinadobrzyn I think we should have an existing regression test for this. If it's this specific case then we should just update the test case to cover URL with spaces. What do you think?

  17. Christinadobrzyn commented on Nov 24, 2025

    @Christinadobrzyn
    Contributor

    It looks like this is the current regression test:

    Step 01
    For scanning, you can use a personal receipt file or download a test file here

    1. Navigate to the workspace chat as the employee
    2. Select the option to Submit expense > Scan receipt
    3. Select the option to upload a receipt
    4. Android/iOS only Verify the full screen loader is displayed when opening the image picker
    5. Verify you can select a file stored in the testing device
    6. Verify the full screen loader disappears once the image picker is closed
    7. Upload a receipt file
    8. Upload the file that has spaces in the filename
    9. Verify a preview of the file is displayed in the final review page
    10. Click on the receipt to open the image to see it fully
    11. Verify that Replace and Download options are in three dot menu
    12. Click on both the options and verify both options works well
    13. Click on Submit expense
    14. Verify the request preview contains a thumbnail of the receipt
    15. Navigate to the request conversation
    16. Verify the request has a Next Step status of "Receipt Scan in progress. Check back later or enter the details below"
    17. Verify the message preview in LHN shows as "Receipt Scan in progress.."
    18. Verify there's a banner in the header indicating the scan is in progress and "Receipt scan in progress. Check back later or enter the details now."
    19. Click on the receipt of the expense created while it is still scanning
    20. Verify that the download button appears in the top-right corner of the attachment modal

    Result:

    • User is able to upload a receipt file with the scan option
    • The thumbnails of the file should be the correct ones during the creation process and once created
    • While the receipt is scanning, a banner should be displayed in the header indicating the status or to enter the details manually

    @mananjadhav can you confirm the above looks good?

  18. Christinadobrzyn commented on Nov 24, 2025

    @Christinadobrzyn
    Contributor

    Payment summary here - #74685 (comment)

  19. TaduJR commented on Nov 25, 2025

    @TaduJR
    Contributor

    Thank you @Christinadobrzyn

    Offer Accepted.

  20. Christinadobrzyn commented on Nov 26, 2025

    @Christinadobrzyn
    Contributor

    nudge @mananjadhav to review the regression test proposal here - #74685 (comment)

  21. mananjadhav commented on Nov 26, 2025

    @mananjadhav
    Collaborator

    Missed this @Christinadobrzyn. I think one additional line would be - Upload the file that has spaces in the filename.

  22. Christinadobrzyn commented on Nov 26, 2025

    @Christinadobrzyn
    Contributor
  23. quinthar commented on Nov 30, 2025

    @quinthar
    Contributor

    $250 approved to @mananjadhav

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions