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] Workspace details don't show up in participants selector #27510

Closed
thienlnam opened this issue Sep 15, 2023 · 30 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

@thienlnam
Copy link
Contributor

thienlnam commented Sep 15, 2023

Clean up for: #25564

When you select a workspace in the new request money flow, the workspace details do not show up.

image

  1. Request money
  2. Select a workspace
  3. Notice that it doesn't contain the details
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~018607cb9d54e7235a
  • Upwork Job ID: 1702632412164861952
  • Last Price Increase: 2023-09-15
  • Automatic offers:
    • situchan | Reviewer | 26745052
    • bernhardoj | Contributor | 26745057
@thienlnam thienlnam added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Sep 15, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

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

@melvin-bot
Copy link

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

@thienlnam thienlnam added the External Added to denote the issue can be worked on by a contributor label Sep 15, 2023
@melvin-bot melvin-bot bot changed the title Workspace details don't show up in participants selector [$500] Workspace details don't show up in participants selector Sep 15, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

Job added to Upwork: https://www.upwork.com/jobs/~018607cb9d54e7235a

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

melvin-bot bot commented Sep 15, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

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

@studentofcoding
Copy link
Contributor

Clean up for: #25564

When you select a workspace in the new request money flow, the workspace details do not show up.

image

  1. Request money
  2. Select a workspace
  3. Notice that it doesn't contain the details

Upwork Automation - Do Not Edit

Hey @thienlnam, the Image is broken, can you re-attach again? thanks!

@situchan
Copy link
Contributor

Screenshot 2023-09-15

@BhuvaneshPatil
Copy link
Contributor

BhuvaneshPatil commented Sep 15, 2023

Proposal

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

What is the root cause of that problem?

Currently we use getParticipantsOptions to find the details for getting the sections items in MoneyRequestParticipantsSelector.
In case of workspace, we have accountID = 0, and we don't find the record for that in personalDetails. and hence the fields are empty and thus we don't have details for them.

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

  1. For first problem
  • Create a new function that will specifically handle the workspaces as participant.
  • it will take two arguments, participants and chatReports
function getParticipatingWorkspace(participants, chatReports) {
    const reportIDs = participants.filter((p) => p.accountID === 0).map((workspace) => workspace.reportID);
    const workspaces = chatReports.filter((report) => {
        return reportIDs.includes(report.reportID);
    });
    return workspaces;
}

It will filter the workspaces from recent chatReports and return the participating workspaces. we then concat this array for sections in MoneyRequestParticipantSelector, in the following section's data

newSections.push({
title: undefined,
data: OptionsListUtils.getParticipantsOptions(participants, personalDetails),
shouldShow: true,
indexOffset,
});

The code can be cleaned and handle the conditions better.
result -
Screenshot 2023-09-15 at 5 06 03 PM

  1. For second problem
    While getting value for isSelected in BaseOptionsList, we are only taking accountID into consideration, but as workspaces have accountID as 0, all workspaces shown as selected.
if (option.accountID && option.accountID === item.accountID) return true
if (option.reportID && option.reportID === item.reportID) return true

and while selecting more than one participants, we are not adding the reportID to participant object, as we do while selecting the subsequent participant here -

newSelectedOptions = [...participants, {accountID: option.accountID, login: option.login, selected: true}];

We shall add reportID here as well

What alternative solutions did you explore? (Optional)

  • For first problem, we can use getPolicyExpenseReportOptions to get the details about the workspace if we don't want to create a new function.

@bernhardoj
Copy link
Contributor

bernhardoj commented Sep 16, 2023

Proposal

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

I see there are 2 issues.

  1. Selecting workspace as a split bill participant shows an empty detail
  2. Selecting one workspace will show other workspaces as selected

What is the root cause of that problem?

In the participant page, the participant detail is coming from OptionsListUtils.getParticipantsOptions

newSections.push({
title: undefined,
data: OptionsListUtils.getParticipantsOptions(participants, personalDetails),

function getParticipantsOptions(participants, personalDetails) {
const details = getPersonalDetailsForAccountIDs(_.pluck(participants, 'accountID'), personalDetails);
return _.map(participants, (participant) => {
const detail = details[participant.accountID];
const login = detail.login || participant.login;
const displayName = detail.displayName || LocalePhoneNumber.formatPhoneNumber(login);
return {
keyForList: String(detail.accountID),
login,
accountID: detail.accountID,

It only works for a user as it gets the detail from personal details onyx based on accountID.

In BaseOptionsList, we have a logic to detect whether an item is selected or not by comparing the accountID.

const renderItem = ({item, index, section}) => {
const isItemDisabled = isDisabled || section.isDisabled || !!item.isDisabled;
const isSelected = _.some(selectedOptions, (option) => {
if (option.accountID === item.accountID) {
return true;
}

However, workspace accountID is 0, so the condition is always true as both value is 0.

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

Below solutions assume that we can split bill with more than 1 workspace

For the first problem, we should use OptionsListUtils.getPolicyExpenseReportOptions to get the details for workspace participants. We already do this on the confirmation page.

const participants = useMemo(
() =>
lodashGet(props.iou.participants, [0, 'isPolicyExpenseChat'], false)
? OptionsListUtils.getPolicyExpenseReportOptions(props.iou.participants[0])
: OptionsListUtils.getParticipantsOptions(props.iou.participants, props.personalDetails),
[props.iou.participants, props.personalDetails],
);

But because we can now select a user along with a workspace as participants, we need to adjust the above code a little bit. We will map each participant to use either getPolicyExpenseReportOptions or getParticipantsOptions (on both participant and confirmation page).

participants.map(participant => {
    const isPolicyExpenseChat = lodashGet(participant, 'isPolicyExpenseChat', false);
    return isPolicyExpenseChat ? OptionsListUtils.getPolicyExpenseReportOptions(participant) : OptionsListUtils.getParticipantsOptions(participant, personalDetails)
})

This also means we need to update both getPolicyExpenseReportOptions and getParticipantsOptions to return an object instead of an array.

However, this still won't work because we need isPolicyExpenseChat and reportID for workspace participants. When we select a participant for split, it will only have these properties.

newSelectedOptions = [...participants, {accountID: option.accountID, login: option.login, selected: true}];

We need to include both isPolicyExpenseChat and reportID into it as we do in addSingleParticipant.

const addSingleParticipant = (option) => {
onAddParticipants([{accountID: option.accountID, login: option.login, isPolicyExpenseChat: option.isPolicyExpenseChat, reportID: option.reportID, selected: true}]);

For the second problem, currently, the option item selected logic only considers the accountID of the participant, but the workspace doesn't have that and we need to rely on reportID for the workspace.

const isSelected = _.some(selectedOptions, (option) => {
if (option.accountID === item.accountID) {
return true;
}

So, we need to make sure accountID exists before comparing and also need to compare for a reportID.

if (option.accountID && option.accountID === item.accountID) return true
if (option.reportID && option.reportID === item.reportID) return true

Last, after fixing it all, I realize we still have another selection issue. Selecting a second workspace participant will deselect all workspaces and the root cause is the same as above and needs the same solution as above.

const isOptionInList = _.some(participants, (selectedOption) => selectedOption.accountID === option.accountID);
let newSelectedOptions;
if (isOptionInList) {
newSelectedOptions = _.reject(participants, (selectedOption) => selectedOption.accountID === option.accountID);

note: the solution will crash if we select a user participant along with workspace, but we have an issue to not allow that nvm, I just reread the discussion and understand the expected behavior and updated my proposal

@thienlnam
Copy link
Contributor Author

@situchan Mind reviewing these proposals today? This is a bit of a critical issue with the new global create

@situchan
Copy link
Contributor

Sure!

@situchan
Copy link
Contributor

@BhuvaneshPatil @bernhardoj thanks for the proposals.
While @BhuvaneshPatil first identified both issues with the root cause, @bernhardoj provided more detailed solution with regression fixes.
Also I checked edited timeline and @bernhardoj first proposed complete solution.
So I'd like to go with @bernhardoj's proposal.
🎀 👀 🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Sep 18, 2023

Current assignee @thienlnam is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@strepanier03
Copy link
Contributor

@bernhardoj @situchan - Would the fix here resolve this report as well?

@kbecciv for visibility.

@situchan
Copy link
Contributor

@strepanier03 yes, should be fixed here

cc: @bernhardoj

@melvin-bot
Copy link

melvin-bot bot commented Sep 18, 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.

@chiragsalian
Copy link
Contributor

Once the PR is done i think we should CP it so that it addresses the blocker.

@bernhardoj
Copy link
Contributor

@strepanier03 yes, it would resolve the empty user after going back.

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

melvin-bot bot commented Sep 19, 2023

📣 @situchan 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot
Copy link

melvin-bot bot commented Sep 19, 2023

📣 @bernhardoj 🎉 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 📖

@bernhardoj
Copy link
Contributor

bernhardoj commented Sep 19, 2023

@situchan I can't finish the recording because of the freezing issue #27713. It is a different issue from what we have here. I remember that it works fine when working on the proposal and I found that this PR is the one that causes the freeze.

I think we should fix that first before continuing

@situchan
Copy link
Contributor

@bernhardoj if that is the offending PR, please continue test after reverting it locally.

@bernhardoj
Copy link
Contributor

PR is ready

@melvin-bot
Copy link

melvin-bot bot commented Sep 20, 2023

🎯 ⚡️ Woah @situchan / @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-09-19 03:22:17 Z
  • when the PR got merged: 2023-09-20 07:10:03 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 20, 2023
@melvin-bot melvin-bot bot changed the title [$500] Workspace details don't show up in participants selector [HOLD for payment 2023-09-29] [$500] Workspace details don't show up in participants selector 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:

  • [@situchan] The PR that introduced the bug has been identified. Link to the PR:
  • [@situchan] 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:
  • [@situchan] 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:
  • [@situchan] Determine if we should create a regression test for this bug.
  • [@situchan] 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.
  • [@sophiepintoraetz] 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 Overdue and removed Weekly KSv2 labels Sep 29, 2023
@sophiepintoraetz
Copy link
Contributor

Payouts due:

Issue Reporter: N/A
Contributor: $750 @bernhardoj
Contributor+: $750 @situchan (once you have completed the BZ checklist, I'll release payment!)

Eligible for 50% #urgency bonus? Y

@melvin-bot melvin-bot bot removed the Overdue label Oct 2, 2023
@situchan
Copy link
Contributor

situchan commented Oct 2, 2023

No regression. This was clean-up of #25564 in Simplify Global Create project.
I think regression test will be part of https://github.com/Expensify/Expensify/issues/318720

@sophiepintoraetz
Copy link
Contributor

Ah good point - @thienlnam - can you confirm there is a regression test included for this bug in https://github.com/Expensify/Expensify/issues/318720?

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

8 participants