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

[HOLD for payment 2023-09-29] [$500] Request money - Scan - Brief disappearance of "Attachment too small" modal text before modal closure #27274

Closed
1 of 6 tasks
izarutskaya opened this issue Sep 12, 2023 · 34 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Sep 12, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Open a chat
  2. Navigate to "Request money" > "Scan"
  3. Attempt to upload a text file or incorrect file
  4. Click on the "Close" button
  5. Notice the "Attachment too small" modal text briefly disappears for a moment before the modal closes

Expected Result:

The "Attachment too small" modal text should remain visible without disappearance before the modal closes

Actual Result:

Brief disappearance of "Attachment too small" modal text before modal closure

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: v1.3.68-13

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

Notes/Photos/Videos: Any additional supporting documentation

screen-recording-2023-09-09-at-124504-am-nrxf8tiu_13kW677f.mp4
Recording.1517.mp4

Expensify/Expensify Issue URL:

Issue reported by: @ayazhussain79

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1694202685326599

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01fc29b362e680f18d
  • Upwork Job ID: 1701645130088493056
  • Last Price Increase: 2023-09-12
  • Automatic offers:
    • jjcoffee | Reviewer | 26724139
    • dukenv0307 | Contributor | 26724141
@dukenv0307
Copy link
Contributor

Proposal

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

Brief disappearance of "Attachment too small" modal text before modal closure

What is the root cause of that problem?

  1. When we upload an invalid file in Scan receipt, this modal appears to show the error message, and the isVisible is set to isAttachmentInvalid

<ConfirmModal
title={attachmentInvalidReasonTitle}
onConfirm={Receipt.clearUploadReceiptError}
onCancel={Receipt.clearUploadReceiptError}
isVisible={isAttachmentInvalid}
prompt={attachmentInvalidReason}
confirmText={translate('common.close')}
shouldShowCancelButton={false}
/>

  1. We get the isAttachmentInvalid, attachmentInvalidReasonTitle, attachmentInvalidReason from ONYXKEYS.RECEIPT_MODAL in Onyx.

const isAttachmentInvalid = lodashGet(props.receiptModal, 'isAttachmentInvalid', false);
const attachmentInvalidReasonTitle = lodashGet(props.receiptModal, 'attachmentInvalidReasonTitle', '');
const attachmentInvalidReason = lodashGet(props.receiptModal, 'attachmentInvalidReason', '');

  1. When we Close the error modal, we trigger this function to clear the error.

function clearUploadReceiptError() {

  1. But in the BaseModal, we have an animation that FadeOut when closing the modal that delays the updation of isAttachmentInvalid

animationOut={animationOut || modalStyleAnimationOut}

As a result, the attachmentInvalidReasonTitle, and attachmentInvalidReason are set to empty strings first, this makes the text disappear before the modal is completely closed.

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

  1. In src/libs/actions/Receipt.ts, we should create a new function closeUploadReceiptModal to update the isAttachmentInvalid to false in order to close the modal
function closeUploadReceiptModal() {
    Onyx.merge(ONYXKEYS.RECEIPT_MODAL, {
        isAttachmentInvalid: false,
    });
}
  1. Pass this function to onConfirm and onCancel functions to close the modal when we click the Close button

  1. Add onModalHide prop to ConfirmModal, and pass the Receipt.clearUploadReceiptError function so that we can successfully clear all the error messages once the modal is completely closed

What alternative solutions did you explore? (Optional)

  • In the clearUploadReceiptError function, instead of setting both attachmentInvalidReasonTitle and attachmentInvalidReason to empty strings, we just need to update
    the isAttachmentInvalid to false in Onyx.

function clearUploadReceiptError() {

Result

Screen.Recording.2023-09-12.at.14.43.19.mov

@izarutskaya izarutskaya added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 12, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 12, 2023

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

@melvin-bot melvin-bot bot changed the title Request money - Scan - Brief disappearance of "Attachment too small" modal text before modal closure [$500] Request money - Scan - Brief disappearance of "Attachment too small" modal text before modal closure Sep 12, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 12, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01fc29b362e680f18d

@melvin-bot
Copy link

melvin-bot bot commented Sep 12, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 12, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 12, 2023

Triggered auto assignment to @NicMendonca (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 12, 2023

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

@oogushikun
Copy link
Contributor

Proposal

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

Brief disappearance of "Attachment too small" modal text before modal closure

What is the root cause of that problem?

The issue is coming from the ReceiptSelector component. The prop receiptModal coming from onyx is being reset to it's initial state before the modal gets closed.

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

  • Introduce a state variable to handle the modal visibility
const [showModal, setShowModal] = useState(false);
  • Add a useffect to update the new state variable when the receipt is invalidated
    useEffect(() => {
        if (isAttachmentInvalid) {
            setShowModal(true);
        }
    }, [isAttachmentInvalid]);
  • Add a new function that will be called when we close the modal. The function will set the showModal state variable to false, and once that's done it'll then call the receipt action clearUploadReceiptError.
    const closeModal = () => {
        setShowModal(false, () => {
            Receipt.clearUploadReceiptError();
        });
    }
    <ConfirmModal
        title={attachmentInvalidReasonTitle}
        onConfirm={closeModal}
        onCancel={closeModal}
        isVisible={showModal}
        prompt={attachmentInvalidReason}
        confirmText={translate('common.close')}
        shouldShowCancelButton={false}
    />

Result

receiptselector-1.mov

@melvin-bot
Copy link

melvin-bot bot commented Sep 12, 2023

📣 @oogushikun! 📣
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. 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.
  2. 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.
  3. 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>

@melvin-bot
Copy link

melvin-bot bot commented Sep 12, 2023

⚠️ Invalid email. Please make sure to create an Expensify account with this email first here.

@melvin-bot
Copy link

melvin-bot bot commented Sep 12, 2023

⚠️ Missing/invalid email or upwork profile link. Please make sure you add both your Expensify email and Upwork profile link in the format specified.

2 similar comments
@melvin-bot
Copy link

melvin-bot bot commented Sep 12, 2023

⚠️ Missing/invalid email or upwork profile link. Please make sure you add both your Expensify email and Upwork profile link in the format specified.

@melvin-bot
Copy link

melvin-bot bot commented Sep 12, 2023

⚠️ Missing/invalid email or upwork profile link. Please make sure you add both your Expensify email and Upwork profile link in the format specified.

@hungvu193
Copy link
Contributor

Proposal

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

Request money - Scan - Brief disappearance of "Attachment too small" modal text before modal closure

What is the root cause of that problem?

We're storing the error states in Onyx, when dismissing the modal, we will see the texts disappeared then modal disappeared since we had 300ms for the animation.

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

We're storing file validation in Onyx which makes it inconsistent with other places, and it also causes another issue when the page refreshed, error didn't clear. If we use local state we can resolve both issues.

  1. Update isAttachmentInvalid, attachmentInvalidReasonTitle, attachmentInvalidReason to local state.
 const [isAttachmentInvalid, setIsAttachmentInvalid] = useState(false);
 const [attachmentInvalidReasonTitle, setAttachmentInvalidReasonTitle] = useState('');
 const [attachmentInvalidReason, setAttachmentInvalidReason] = useState('');
  1. Update validateReceipt function:
    const validateReceipt = (file) => {
        const {fileExtension} = FileUtils.splitExtensionFromFileName(lodashGet(file, 'name', ''));
        if (_.contains(CONST.API_ATTACHMENT_VALIDATIONS.UNALLOWED_EXTENSIONS, fileExtension.toLowerCase())) {
            setAttachmentInvalidReason('attachmentPicker.wrongFileType');
            setAttachmentInvalidReasonTitle('attachmentPicker.notAllowedExtension');
            return false;
        }
    
        if (lodashGet(file, 'size', 0) > CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE) {
            setAttachmentInvalidReason('attachmentPicker.wrongFileType');
            setAttachmentInvalidReasonTitle('attachmentPicker.notAllowedExtension');
            return false;
        }
    
        if (lodashGet(file, 'size', 0) < CONST.API_ATTACHMENT_VALIDATIONS.MIN_SIZE) {
            setAttachmentInvalidReason('attachmentPicker.wrongFileType');
            setAttachmentInvalidReasonTitle('attachmentPicker.notAllowedExtension');
            return false;
        }
    
        return true;
    }
  1. Update setReceiptAndNavigate:
        if (!validateReceipt(file)) {
            setIsAttachmentInvalid(true);
            return;
        }
  1. Finally update the onConfirm and onCancel:
   onConfirm={() => setIsAttachmentInvalid(false)}
   onCancel={() => setIsAttachmentInvalid(false)}

What alternative solutions did you explore? (Optional)

N/A

Result
Screen.Recording.2023-09-13.at.14.06.22.mov

@melvin-bot melvin-bot bot added the Overdue label Sep 15, 2023
@jjcoffee
Copy link
Contributor

@dukenv0307's proposal LGTM! The RCA is correct (the errors are set to empty strings before the modal hide animation completes), and the solution correctly addresses the RCA.

With @oogushikun's proposal we already have a onModalHide prop so it would be an unnecessary use of state to store modal visibility there.

@hungvu193's proposal has an incorrect RCA as the issue doesn't come down to using Onyx (it might be true that we're not standardised on using Onyx for storing errors, but it's irrelevant to this issue).

🎀👀🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

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

@johnmlee101
Copy link
Contributor

Makes sense!

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 18, 2023
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 18, 2023
@dukenv0307
Copy link
Contributor

dukenv0307 commented Sep 18, 2023

@jjcoffee The PR is ready for review: #27635
I have some trouble when scanning receipts on mobile ( granting permission for the camera is not working ), I will update it as soon as possible

@dukenv0307
Copy link
Contributor

@jjcoffee due to this reply, https://expensify.slack.com/archives/C01GTK53T8Q/p1695028441217399?thread_ts=1695028058.612099&cid=C01GTK53T8Q
Can I omit the records in the iOS and Android simulators, since the actual error is only happening on the web?

@jjcoffee
Copy link
Contributor

@dukenv0307 Are you able to use the gallery (bottom left) to attach an image to scan?

@jjcoffee
Copy link
Contributor

@dukenv0307 So I've tested on iOS native by selecting a tiny PNG (<240 bytes) from the gallery, but no file size validation seems to run. I don't think that's related to your changes and think adding it would be OOS for this PR.

Since there's no validation running, there's no need to test your changes as such, but it's good just to have a test of the flow anyway (so just uploading any image from the gallery). cc @johnmlee101

@melvin-bot
Copy link

melvin-bot bot commented Sep 20, 2023

🎯 ⚡️ Woah @jjcoffee / @dukenv0307, great job pushing this forwards! ⚡️

The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus 🎉

  • when @dukenv0307 got assigned: 2023-09-18 03:04:05 Z
  • when the PR got merged: 2023-09-20 01:20:54 UTC

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Sep 22, 2023
@melvin-bot melvin-bot bot changed the title [$500] Request money - Scan - Brief disappearance of "Attachment too small" modal text before modal closure [HOLD for payment 2023-09-29] [$500] Request money - Scan - Brief disappearance of "Attachment too small" modal text before modal closure Sep 22, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.72-11 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 2023-09-29. 🎊

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.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

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

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

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:

  • [@jjcoffee] The PR that introduced the bug has been identified. Link to the PR:
  • [@jjcoffee] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@jjcoffee] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@jjcoffee] Determine if we should create a regression test for this bug.
  • [@jjcoffee] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@kadiealexander] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@kadiealexander kadiealexander added Daily KSv2 and removed Weekly KSv2 labels Sep 29, 2023
@kadiealexander
Copy link
Contributor

kadiealexander commented Sep 29, 2023

Payouts due:

Eligible for 50% #urgency bonus? Yes

Upwork job is here.

@kadiealexander
Copy link
Contributor

@jjcoffee please complete the BugZero Checklist.

@ayazhussain79 please accept the Upwork contract I sent across.

@ayazhussain79
Copy link
Contributor

@kadiealexander offer accepted, Thank you

@jjcoffee
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: N/A - behaviour has been there since the original PR that added the feature.
  • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: N/A
  • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
  • Determine if we should create a regression test for this bug. No - low impact
  • If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again. N/A

@jjcoffee
Copy link
Contributor

@kadiealexander Checklist complete!

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Daily KSv2 labels Sep 29, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

@johnmlee101, @jjcoffee, @kadiealexander, @dukenv0307 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@kadiealexander
Copy link
Contributor

Everyone is paid!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

9 participants