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-07-21] [$1000] Share somewhere doesn't update in room while selecting user/group #21614

Closed
1 of 6 tasks
kavimuru opened this issue Jun 26, 2023 · 62 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

@kavimuru
Copy link

kavimuru commented Jun 26, 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!


Action Performed:

  1. Create a room
  2. select '+" icon and click assign task ( It must be done within room)
  3. Add title and description
  4. Go to share somewhere and click on any other rooms/ contact list.
    ( Notice that while clicking other groups too, only default room on which the task is created is shown.)

Expected Result:

Either, multiple groups should be selectable and should be updated as like assign task done from LHN,
OR, sharing somewhere should be made unchooseable, and only default room should be shown

Actual Result:

Share somewhere doesn't update in room while selecting user/group

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

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: 1.3.32-5
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

Recording.5175.mp4
Screen.Recording.2023-06-21.at.6.19.37.PM.mov

Expensify/Expensify Issue URL:
Issue reported by: @ashimsharma10
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1687351420861259

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01cdc2396412f39341
  • Upwork Job ID: 1674191448143474688
  • Last Price Increase: 2023-07-05
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 26, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jun 26, 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

@StevenKKC
Copy link
Contributor

StevenKKC commented Jun 26, 2023

Proposal

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

Share somewhere doesn't update in room while selecting user/group.

What is the root cause of that problem?

When select user/group in share somewhere page, task.shareDestination will be set.

if (option.reportID) {
// Clear out the state value, set the assignee and navigate back to the NewTaskPage
setSearchValue('');
TaskUtils.setShareDestinationValue(option.reportID);
Navigation.goBack();
}

After return to create task page, because task.parentReportID is set, task.shareDestination will be set to original value.
if (props.task.parentReportID) {
TaskUtils.setShareDestinationValue(props.task.parentReportID);
}

Therefor share somewhere doesn't update.

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

When select user/group, we should clear task.parentReportID in TaskShareDestinationSelectorModal.

        if (option.reportID) {
            // Clear out the state value, set the assignee and navigate back to the NewTaskPage
            setSearchValue('');
            TaskUtils.setShareDestinationValue(option.reportID);
+           TaskUtils.setParentReportID(null);
            Navigation.goBack();
        }

setParentReportID function is not exported in Task.js, so we should export setParentReportID function.

What alternative solutions did you explore? (Optional)

None.

@melvin-bot
Copy link

melvin-bot bot commented Jun 26, 2023

Looks like something related to react-navigation may have been mentioned in this issue discussion.

As a reminder, please make sure that all proposals are not workarounds and that any and all attempt to fix the issue holistically have been made before proceeding with a solution. Proposals to change our DeprecatedCustomActions.js files should not be accepted.

Feel free to drop a note in #expensify-open-source with any questions.

@Nikhil-Vats
Copy link
Contributor

Nikhil-Vats commented Jun 26, 2023

Proposal

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

Share somewhere doesn't update when creating a task from a chat (report).

What is the root cause of that problem?

In TaskShareDestinationSelectorModal, we don't update parentReportID when updating share destination -

if (option.reportID) {
// Clear out the state value, set the assignee and navigate back to the NewTaskPage
setSearchValue('');
TaskUtils.setShareDestinationValue(option.reportID);
Navigation.goBack();
}

In NewTaskPage we override the share somewhere in the lines below so it cannot be changed to any user/group/room other than the parent report if we create a task from a report.

// We only set the parentReportID if we are creating a task from a report
// this allows us to go ahead and set that report as the share destination
// and disable the share destination selector
if (props.task.parentReportID) {
TaskUtils.setShareDestinationValue(props.task.parentReportID);
}

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

We should also change the parentReportID when changing the share somewhere destination in TaskShareDestinationSelectorModal -

To do that, we can call the setParentReportID in setShareDestinationValue function in TaskUtils -

/**
 * Sets the shareDestination value for the task
 * @param {string} shareDestination
 */
function setShareDestinationValue(shareDestination) {
    // This is only needed for creation of a new task and so it should only be stored locally
    Onyx.merge(ONYXKEYS.TASK, {shareDestination});
    setParentReportID(shareDestination); // call this function also when changing the share destination
    // this will also update the parentReportID so that share destination will not be overridden in `NewTaskPage`
}

setParentReportID is defined after setShareDestinationValue so we will need to reorder and define setParentReportID before setShareDestinationValue to use it in setShareDestinationValue.

Alternatively, we can export setParentReportID and use it in TaskShareDestinationSelectorModal -

if (option.reportID) {
    // Clear out the state value, set the assignee and navigate back to the NewTaskPage
    setSearchValue('');
    TaskUtils.setShareDestinationValue(option.reportID); // alternatively, call `setParentReportID` in this function and remove next line
    TaskUtils.setParentReportID(option.reportID);
    Navigation.goBack();
}

What alternative solutions did you explore? (Optional)

Since, the user has clicked on assign task from a chat and not FAB in LHN, we can make the share somewhere field un-interactive when creating a task from a report.

This is consistent with send/request money in a report. We do not let user change the payee in request/send money page if they opened the page from a report.

To disable share somewhere when we click on assign task from a report, we can use the interactive prop to make it non interactive if parentReportID is set -

<MenuItem
    label={shareDestination.displayName ? props.translate('newTaskPage.shareSomewhere') : ''}
    title={shareDestination.displayName || ''}
    description={shareDestination.displayName ? shareDestination.subtitle : props.translate('newTaskPage.shareSomewhere')}
    icon={shareDestination.icons}
    onPress={() => Navigation.navigate(ROUTES.NEW_TASK_SHARE_DESTINATION)}
    interactive={!Boolean(props.task.parentReportID)} // make the field non interactive if parentReportID is set
    shouldShowRightIcon={!Boolean(props.task.parentReportID)} // don't show right icon if parentReportID is set
/>
Screen.Recording.2023-07-07.at.11.12.53.PM.mov

@bernhardoj
Copy link
Contributor

bernhardoj commented Jun 27, 2023

Proposal

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

We can't change the Share Somewhere field when creating a task within a report.

What is the root cause of that problem?

When we are creating a task within a report, it will autofill the Share Somewhere field (currently it's not working because of this issue) with the report we initiated the new task on.

// We only set the parentReportID if we are creating a task from a report
// this allows us to go ahead and set that report as the share destination
// and disable the share destination selector
if (props.task.parentReportID) {
TaskUtils.setShareDestinationValue(props.task.parentReportID);
}

parentReportID is the ID of the report on which we initiated the new task.

The problem is, the code above is put inside a useEffect with a dependency array of [props] which means it will rerun every time ANY props are changed. This will produce unexpected side effects as we have in this issue.

In this case, when we select a new Share Somewhere, it will also trigger the code above which will just override the new selected Share Somewhere with the parentReportID.

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

To prevent any unexpected side effects, we should extract it out into a separate useEffect with a dependency array that is only needed, in this case, props.task.parentReportID.

useEffect(() => {
    if (props.task.parentReportID) {
        TaskUtils.setShareDestinationValue(props.task.parentReportID);
    }
}, [props.task.parentReportID]);

We can do the same thing to all (4) conditions inside the useEffect.

useEffect(() => {
setErrorMessage('');
// If we have an assignee, we want to set the assignee data
// If there's an issue with the assignee chosen, we want to notify the user
if (props.task.assignee) {
const assigneeDetails = lodashGet(OptionsListUtils.getPersonalDetailsForAccountIDs([props.task.assigneeAccountID], props.personalDetails), props.task.assigneeAccountID);
if (!assigneeDetails) {
return setErrorMessage(props.translate('newTaskPage.assigneeError'));
}
const displayDetails = TaskUtils.getAssignee(assigneeDetails);
setAssignee(displayDetails);
}
// If we don't have an assignee and we are creating a task from a report
// this allows us to auto assign a participant of the report.
if (!props.task.assignee && props.task.parentReportID) {
TaskUtils.setAssigneeValueWithParentReportID(props.task.parentReportID);
}
// We only set the parentReportID if we are creating a task from a report
// this allows us to go ahead and set that report as the share destination
// and disable the share destination selector
if (props.task.parentReportID) {
TaskUtils.setShareDestinationValue(props.task.parentReportID);
}
// If we have a share destination, we want to set the parent report and
// the share destination data
if (props.task.shareDestination) {
setParentReport(lodashGet(props.reports, `report_${props.task.shareDestination}`, {}));
const displayDetails = TaskUtils.getShareDestination(props.task.shareDestination, props.reports, props.personalDetails);
setShareDestination(displayDetails);
}
}, [props]);

What alternative solutions did you explore? (Optional)

We can use interactive props (apply to the MenuItem) to "disable" the Share somewhere field.

interactive={!Boolean(props.task.parentReportID)}
shouldShowRightIcon={!Boolean(props.task.parentReportID)}

@melvin-bot melvin-bot bot added the Overdue label Jun 28, 2023
@alexpensify alexpensify added the External Added to denote the issue can be worked on by a contributor label Jun 28, 2023
@melvin-bot melvin-bot bot changed the title Share somewhere doesn't update in room while selecting user/group [$1000] Share somewhere doesn't update in room while selecting user/group Jun 28, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 28, 2023

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

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

melvin-bot bot commented Jun 28, 2023

Current assignee @alexpensify is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Jun 28, 2023

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

@alexpensify
Copy link
Contributor

alexpensify commented Jun 28, 2023

Adding the external label because I'm able to reproduce. @sobitneupane to keep us moving forward, can you review if any of these proposals will correct the issue? Thanks!

2023-06-28_16-00-12

image

@melvin-bot melvin-bot bot removed the Overdue label Jun 28, 2023
@thienlnam
Copy link
Contributor

This is a duplicate of #20898

@alexpensify
Copy link
Contributor

Whoops I missed that one when checked GH. I'm closing and I closed the job in upwork too

@bernhardoj
Copy link
Contributor

Looking into the root cause of #20898, I think the issue is different. #20898 issue is about selecting a chat that doesn't exist and the solution is to only show chat/report that exist in the list.

In this issue, we select an exist chat/report, but then the value is overwritten because of an unexpected side effect of useEffect

@ashimsharma10
Copy link

I second @bernhardoj . in this issue we are talking about the selected user not being saved.

@thienlnam thienlnam self-assigned this Jun 29, 2023
@melvin-bot

This comment was marked as off-topic.

@melvin-bot

This comment was marked as off-topic.

@thienlnam
Copy link
Contributor

Thanks for the comment - since they were both regarding a selection in share somewhere not working I assumed it was the same - will open this back up

@melvin-bot melvin-bot bot added the Reviewing Has a PR in review label Jul 11, 2023
@bernhardoj
Copy link
Contributor

PR is ready

cc: @sobitneupane

@ashimsharma10
Copy link

My upwork profile is : https://www.upwork.com/freelancers/~018a92cf13e1e88eed .

Idk why its needed again.

@melvin-bot
Copy link

melvin-bot bot commented Jul 11, 2023

🎯 ⚡️ Woah @sobitneupane / @bernhardoj, 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 @bernhardoj got assigned: 2023-07-10 18:19:02 Z
  • when the PR got merged: 2023-07-11 17:38:59 UTC

On to the next one 🚀

@alexpensify
Copy link
Contributor

Great work team, now we will wait for automation here.

@alexpensify
Copy link
Contributor

Still waiting for automation

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Jul 14, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Share somewhere doesn't update in room while selecting user/group [HOLD for payment 2023-07-21] [$1000] Share somewhere doesn't update in room while selecting user/group Jul 14, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 14, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 14, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.40-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-07-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

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 Jul 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:

  • [@sobitneupane] The PR that introduced the bug has been identified. Link to the PR:
  • [@sobitneupane] 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:
  • [@sobitneupane] 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:
  • [@sobitneupane] Determine if we should create a regression test for this bug.
  • [@sobitneupane] 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.
  • [@alexpensify] 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 Jul 20, 2023
@alexpensify
Copy link
Contributor

@ashimsharma10 and @bernhardoj - I've sent the payment request via Upwork. I had to use a new job link, please accept and I can complete the required process.


@sobitneupane - Please complete the checklist and request payment via Chat.


Thank you!

@bernhardoj
Copy link
Contributor

Accepted

@alexpensify
Copy link
Contributor

@ashimsharma10 and @bernhardoj - I've completed the payment process via Upwork!


@sobitneupane - please complete the checklist, so we can continue with the next steps for payment here and we can close the GH out. Thank you!

@bernhardoj
Copy link
Contributor

Thanks!

@sobitneupane
Copy link
Contributor

sobitneupane commented Jul 24, 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:

  • [@sobitneupane] The PR that introduced the bug has been identified. Link to the PR:

#20145

  • [@sobitneupane] 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:

https://github.com/Expensify/App/pull/20145/files#r1272428756

  • [@sobitneupane] 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:

This should have been caught in PR review. No change in PR review checklist required.

  • [@sobitneupane] Determine if we should create a regression test for this bug.

Yes.

  • [@sobitneupane] 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.

#21614 (comment)

@sobitneupane
Copy link
Contributor

Regression Test Proposal

  1. Open any chat
  2. Press the + button in Composer
  3. Press Assign Task
  4. Enter any title and press Next
  5. Verify Share somewhere doesn't have a right arrow
  6. Verify pressing/clicking Share somewhere doesn't do anything
  7. Now, go back to LHN and press the FAB + button
  8. Repeat steps 3-4
  9. Verify Share somewhere has a right arrow
  10. Verify pressing/clicking Share somewhere open a new page to select a report

Do we agree 👍 or 👎

@sobitneupane
Copy link
Contributor

Requested payment on newDot.

@alexpensify
Copy link
Contributor

@sobitneupane, thank you! @thienlnam can you please review the checklist and give a 👍🏼? Thanks.

@thienlnam
Copy link
Contributor

Thumbbed it, looks good to me

@alexpensify
Copy link
Contributor

Thanks, I'm going to close this one out!

@alexpensify
Copy link
Contributor

alexpensify commented Jul 27, 2023

Here is the payment summary:

Upwork Job: https://www.upwork.com/jobs/~01c3b0b1ecadacf47b

*If applicable, the bonuses will be applied on the final payment

Extra Notes regarding payment:

All set here @JmillsExpensify! This one was pre-summary days.

@JmillsExpensify
Copy link

Reviewed details for @sobitneupane. This is accurate based on summary from Business Reviewer and approved for payment in NewDot.

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