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-11-22] [HOLD for payment 2023-11-21] [$500] IOU-In employee WS, in manual request, description entered is not saved in description page #31230

Closed
5 of 6 tasks
izarutskaya opened this issue Nov 11, 2023 · 18 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 Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@izarutskaya
Copy link

izarutskaya commented Nov 11, 2023

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.3.98-0
Reproducible in staging?: Y
Reproducible in production?: N
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. Launch app
  2. Tap on Employee WS
  3. Tap plus icon near compose
  4. Tap request money
  5. Enter an amount
  6. Tap next
  7. Enter description and tap save
  8. Tap request
  9. Tap manual request created
  10. Tap on Description

Expected Result:

In employee WS, in manual request, description entered must be saved in description page.

Actual Result:

In employee WS, in manual request, description entered is not saved in description page.

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6272381_1699702645470.des.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f13c7e52024929d1
  • Upwork Job ID: 1723316971710357504
  • Last Price Increase: 2023-11-11
@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 Nov 11, 2023
Copy link

melvin-bot bot commented Nov 11, 2023

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

@melvin-bot melvin-bot bot changed the title IOU-In employee WS, in manual request, description entered is not saved in description page [$500] IOU-In employee WS, in manual request, description entered is not saved in description page Nov 11, 2023
Copy link

melvin-bot bot commented Nov 11, 2023

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

Copy link

melvin-bot bot commented Nov 11, 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 Nov 11, 2023
Copy link

melvin-bot bot commented Nov 11, 2023

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

@paultsimura
Copy link
Contributor

This is another regression from #28866, changes in EditRequestPage.

We render the edit description form twice, the first time with transaction === {}, therefore propsToParse.defaultValue === "". On the second render, when the transaction is loaded, the form value does not update, because the inputValues[inputID] is not undefined anymore here, but filled with an empty string:

} else if (_.isUndefined(inputValues[inputID])) {
// We want to initialize the input value if it's undefined
inputValues[inputID] = _.isUndefined(propsToParse.defaultValue) ? getInitialValueByType(propsToParse.valueType) : propsToParse.defaultValue;
}

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Nov 11, 2023
@wlegolas
Copy link
Contributor

wlegolas commented Nov 11, 2023

Proposal

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

IOU-In employee WS, in manual request, description entered is not saved in description page

What is the root cause of that problem?

The EditRequestPage component is rendered more than once, and in the first render the transaction props have an empty object, but in the next render process, the transaction props have the correct value.

The description value is extracted from transaction using the method ReportUtils.getTransactionDetails and passed this value to the InputWrapper component, this component registers the input component using the registerInput method from FormProvider, as in the first render the registerInput method was called with an empty string, this value is memoized in the context, that way will generate the default value for this field using the last else if in this expression:

if (!_.isUndefined(propsToParse.value)) {
inputValues[inputID] = propsToParse.value;
} else if (propsToParse.shouldUseDefaultValue) {
// We force the form to set the input value from the defaultValue props if there is a saved valid value
inputValues[inputID] = propsToParse.defaultValue;
} else if (_.isUndefined(inputValues[inputID])) {
// We want to initialize the input value if it's undefined
inputValues[inputID] = _.isUndefined(propsToParse.defaultValue) ? getInitialValueByType(propsToParse.valueType) : propsToParse.defaultValue;
}

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

The registerInput method receives in the second parameter the object propsToParse, this object has a property shouldUseDefaultValue that forces to use the default value.

Use the shouldUseDefaultValue property to force to use the default value:

We should change the EditRequestDescriptionPage component to pass the property shouldUseDefaultValue to the InputWrapperWithRef component.

<View style={styles.mb4}>
<InputWrapperWithRef
// Comment field does not have its modified counterpart
InputComponent={TextInput}
inputID="comment"
name="comment"
defaultValue={defaultDescription}
label={translate('moneyRequestConfirmationList.whatsItFor')}
accessibilityLabel={translate('moneyRequestConfirmationList.whatsItFor')}
role={CONST.ACCESSIBILITY_ROLE.TEXT}
ref={(el) => {
if (!el) {
return;
}
descriptionInputRef.current = el;
updateMultilineInputRange(descriptionInputRef.current);
}}
autoGrowHeight
containerStyles={[styles.autoGrowHeightMultilineInput]}
inputStyle={[styles.verticalAlignTop]}
submitOnEnter={!Browser.isMobile()}
/>
</View>

For example,

<InputWrapperWithRef
    // Comment field does not have its modified counterpart
    InputComponent={TextInput}
    inputID="comment"
    name="comment"
    defaultValue={defaultDescription}
    shouldUseDefaultValue // <- Here we should pass the property
    label={translate('moneyRequestConfirmationList.whatsItFor')}
    accessibilityLabel={translate('moneyRequestConfirmationList.whatsItFor')}
    role={CONST.ACCESSIBILITY_ROLE.TEXT}
    ref={(el) => {
        if (!el) {
            return;
        }
        descriptionInputRef.current = el;
        updateMultilineInputRange(descriptionInputRef.current);
    }}
    autoGrowHeight
    containerStyles={[styles.autoGrowHeightMultilineInput]}
    inputStyle={[styles.verticalAlignTop]}
    submitOnEnter={!Browser.isMobile()}
/>

As the EditRequestDescriptionPage component will always receive the defaultDescription even if the transaction is not available, the field will show the correct value.

Note: I'll try to add some Unit Tests to validate these changes.

Change the registerInput to use the defaultValue if this value is not undefined

In the registerInput, when the property shouldUseDefaultValue is true we need to add another validation, to ensure the propsToParse.defaultValue is not undefined.

With this improvement, we can avoid the problem when the propsToParse.defaultValue is undefined.

if (!_.isUndefined(propsToParse.value)) {
    inputValues[inputID] = propsToParse.value;
} else if (propsToParse.shouldUseDefaultValue && !_.isUndefined(propsToParse.defaultValue)) { // <- Here we need to validate the defaultValue
    // We force the form to set the input value from the defaultValue props if there is a saved valid value
    inputValues[inputID] = propsToParse.defaultValue;
} else if (_.isUndefined(inputValues[inputID])) {
    // We want to initialize the input value if it's undefined
    inputValues[inputID] = _.isUndefined(propsToParse.defaultValue) ? getInitialValueByType(propsToParse.valueType) : propsToParse.defaultValue;
}

What alternative solutions did you explore? (Optional)

Changing the registerInput method to set an initial value in the state inputValues[inputID] when the registerInput method is called, and doing a refactor removing the first condition.

const registerInput = useCallback(
    (inputID, propsToParse = {}) => {
        const newRef = inputRefs.current[inputID] || propsToParse.ref || createRef();
        if (inputRefs.current[inputID] !== newRef) {
            inputRefs.current[inputID] = newRef;
        }

        inputValues[inputID] = propsToParse.value || propsToParse.defaultValue; // <- Here we should set an initial value for the input state.

        if (propsToParse.shouldUseDefaultValue) {
            // We force the form to set the input value from the defaultValue props if there is a saved valid value
            inputValues[inputID] = propsToParse.defaultValue;
        } else if (_.isUndefined(inputValues[inputID])) {
            // We want to initialize the input value if it's undefined
            inputValues[inputID] = _.isUndefined(propsToParse.defaultValue) ? getInitialValueByType(propsToParse.valueType) : propsToParse.defaultValue;
        }

    ...
);

The result will be the same as the changes I put in the section above, but with this change here, we can avoid adding a new condition to validate if the propsToParse.defaultValue is undefined and we have a refactor decreasing the code's complexity.

Note: I'll try to add some Unit Tests to validate these changes.

POC

poc-issue-31230.mov

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Nov 11, 2023
@waitingwittykitty
Copy link

Proposal

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

IOU-In employee WS, in manual request, description entered is not saved in description page

What is the root cause of that problem?

The root cause of the problem is that the registerInput method is called twice. The first time, the value is undefined, causing the input to display an empty string. The next time, it receives a new value from the API, but it does not update because the inputValue is already set to an empty string.

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

To solve the problem, we can add a flag state to the component to indicate if it has been edited by the user. This way, the inputValue will only change by value prop if the user has not already edited it. We can set the flag state to true in the onInputChange function.

What alternative solutions did you explore? (Optional)

As an alternative solution, we can render the input after the API call is finished. During the loading process, we can display a skeleton loader or simply disable the input.

Copy link

melvin-bot bot commented Nov 11, 2023

📣 @waitingwittykitty! 📣
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>

@waitingwittykitty
Copy link

Contributor details
Your Expensify account email: fasterthanclock@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01ab529e479e41351f

Copy link

melvin-bot bot commented Nov 11, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@narefyev91
Copy link
Contributor

narefyev91 commented Nov 13, 2023

Issue was fixed based on this reverted PR #31231

Copy link

melvin-bot bot commented Nov 13, 2023

⚠️ 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.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Nov 14, 2023
@melvin-bot melvin-bot bot changed the title [$500] IOU-In employee WS, in manual request, description entered is not saved in description page [HOLD for payment 2023-11-21] [$500] IOU-In employee WS, in manual request, description entered is not saved in description page Nov 14, 2023
Copy link

melvin-bot bot commented Nov 14, 2023

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 14, 2023
Copy link

melvin-bot bot commented Nov 14, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.98-5 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-11-21. 🎊

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:

Copy link

melvin-bot bot commented Nov 14, 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:

  • [@narefyev91] The PR that introduced the bug has been identified. Link to the PR:
  • [@narefyev91] 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:
  • [@narefyev91] 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:
  • [@narefyev91] Determine if we should create a regression test for this bug.
  • [@narefyev91] 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.
  • [@zanyrenney] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Nov 15, 2023
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2023-11-21] [$500] IOU-In employee WS, in manual request, description entered is not saved in description page [HOLD for payment 2023-11-22] [HOLD for payment 2023-11-21] [$500] IOU-In employee WS, in manual request, description entered is not saved in description page Nov 15, 2023
Copy link

melvin-bot bot commented Nov 15, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.99-0 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-11-22. 🎊

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:

Copy link

melvin-bot bot commented Nov 15, 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:

  • [@narefyev91] The PR that introduced the bug has been identified. Link to the PR:
  • [@narefyev91] 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:
  • [@narefyev91] 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:
  • [@narefyev91] Determine if we should create a regression test for this bug.
  • [@narefyev91] 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.
  • [@zanyrenney] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Nov 21, 2023
@zanyrenney
Copy link
Contributor

Payment summary:
@narefyev91 does not require payment (Contractor)

Closing!

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 Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

6 participants