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

[$1000] [HOLD for payment 2023-05-23] [Manual Requests] Fix participants on the IOUConfirmation page in the case when an admin requests money from the workspace #18708

Closed
mountiny opened this issue May 10, 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 Internal Requires API changes or must be handled by Expensify staff

Comments

@mountiny
Copy link
Contributor

mountiny commented May 10, 2023

Coming from #18215 (comment)

When admin requests money from their workspace as a employee, all the other members of the workspace are shown as participants on the confirmation page when the request is being made

Repro steps

  1. Create a workspace as userA (the admin).
  2. Invite userB
  3. Navigate to your own workspace chat as userA
  4. Tap + > Request Money > enter an amount > next
  5. Observe that the list of participants displayed underneath To are %workspaceName% & userB on the confirmation screen.

Note: The bug only occurs when the admin of the workspace requests money in their own workspace chat. In the above example, if userB requested money in their own workspaceChat, then the To would only show the %workspaceName% as is expected:

image

cc @luacmartins @Julesssss

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019f72dca339218ee5
  • Upwork Job ID: 1661757492474519552
  • Last Price Increase: 2023-05-25
@mountiny mountiny added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 10, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 10, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented May 10, 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

@s77rt
Copy link
Contributor

s77rt commented May 10, 2023

When admin requests money from their workspace as a employee, they are shown as a participant in the IOU preview same as the workspace which is incorrect.

Just a clarification, the admin is not shown as participant, the other members are.

@mountiny
Copy link
Contributor Author

Assinged @trjExpensify for payments and @s77rt to fix this

@trjExpensify
Copy link
Contributor

Dope! @s77rt to confirm, are these the repro steps?

  1. Create a workspace as userA (the admin).
  2. Invite userB
  3. As userA request money in your own workspace chat
  4. Click on the IOUPreview in the chat
  5. Observe that the list of participants underneath To: are WorkspaceName & userB

Also, the bug only occurs when the admin of the workspace requests money in their workspace chat. In the above example, if userB requested money in their own workspaceChat, would a list of all workspace members appear underneath the To as well?

@s77rt
Copy link
Contributor

s77rt commented May 10, 2023

@tjferriss Yes, correct, but not need to finish the request process you can see that the participant list is incorrect at the confirmation step.

As userB the participants list only contains the workspace (no other members) which is the expected behaviour.

Checking now, will post more info asap

@Julesssss
Copy link
Contributor

The screenshot doesn't align with the issue.

@trjExpensify
Copy link
Contributor

Poor TJ man, always getting pinged for @trjExpensify. 😅 😂

Yes, correct, but not need to finish the request process you can see that the participant list is incorrect at the confirmation step.

Ah okay, got it. I've updated the steps and added them to the OP for posterity.

@trjExpensify
Copy link
Contributor

The screenshot doesn't align with the issue.

Yeah, the title of this issue is also wrong. Look at the video it's on the IOUConfirmation screen #18215 (comment)

@trjExpensify trjExpensify changed the title Fix IOUPreview in case admin requests money from the workspace [Manual Requests] Fix participants on the IOUConfirmation page in the case when an admin requests money from the workspace May 10, 2023
@trjExpensify
Copy link
Contributor

Checking now, will post more info asap

Any luck @s77rt? (If there's a slack thread somewhere for this I missed, feel free to point me to it).

@s77rt
Copy link
Contributor

s77rt commented May 10, 2023

a sec.. writing 😁

@s77rt
Copy link
Contributor

s77rt commented May 10, 2023

Problem

Solution

I think the straightforward solution is to filter the report based on isOwnPolicyExpenseChat to differentiate between the workspace report and the other policy expense reports.

diff (may change based on point 2)
diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js
index 83a0b53b40..6dceeb3308 100644
--- a/src/libs/OptionsListUtils.js
+++ b/src/libs/OptionsListUtils.js
@@ -100,26 +100,21 @@ Onyx.connect({
  * @returns {Array}
  */
 function getPolicyExpenseReportOptions(report) {
-    if (!ReportUtils.isPolicyExpenseChat(report)) {
-        return [];
-    }
-    const filteredPolicyExpenseReports = _.filter(policyExpenseReports, (policyExpenseReport) => policyExpenseReport.policyID === report.policyID);
-    return _.map(filteredPolicyExpenseReports, (expenseReport) => {
-        const policyExpenseChatAvatarSource = ReportUtils.getWorkspaceAvatar(expenseReport);
-        return {
-            ...expenseReport,
-            keyForList: expenseReport.policyID,
-            text: expenseReport.displayName,
+    return [
+        {
+            ...report,
+            keyForList: report.policyID,
+            text: report.displayName,
             alternateText: Localize.translateLocal('workspace.common.workspace'),
             icons: [
                 {
-                    source: policyExpenseChatAvatarSource,
-                    name: expenseReport.displayName,
+                    source: ReportUtils.getWorkspaceAvatar(report),
+                    name: report.displayName,
                     type: CONST.ICON_TYPE_WORKSPACE,
                 },
             ],
-        };
-    });
+        },
+    ];
 }
 
 /**
diff --git a/src/pages/iou/MoneyRequestModal.js b/src/pages/iou/MoneyRequestModal.js
index b1bfb9f1ff..abee99e4e9 100644
--- a/src/pages/iou/MoneyRequestModal.js
+++ b/src/pages/iou/MoneyRequestModal.js
@@ -111,7 +111,7 @@ const MoneyRequestModal = (props) => {
     const [previousStepIndex, setPreviousStepIndex] = useState(-1);
     const [currentStepIndex, setCurrentStepIndex] = useState(0);
     const [selectedOptions, setSelectedOptions] = useState(
-        ReportUtils.isPolicyExpenseChat(props.report)
+        ReportUtils.isPolicyExpenseChat(props.report) && props.report.isOwnPolicyExpenseChat
             ? OptionsListUtils.getPolicyExpenseReportOptions(props.report)
             : OptionsListUtils.getParticipantsOptions(props.report, props.personalDetails),
     );

@trjExpensify
Copy link
Contributor

because we create policy expense chats only for the admin

Are you saying that a policyExpenseChat ("Workspace chat") doesn't get created for anyone other than an admin on the workspace? 🤔 I would find that very strange if it was the case. Every member of a workspace should have a workspace chat.

@mountiny
Copy link
Contributor Author

The issue is only reproducible on admin account because we create policy expense chats only for the admin. I'm not sure if this is intended or not.

They are created, maybe the optimistic part does not work smoothly but they are being created for sure

image

I dont think your solution is ideal in this case, the problem is that the getPolicyExpenseReportOptions returns all the options for the user and its intended for the use in the Participants selection view. But we also use the results in here for the confirmation page and we check if the user is not same. Its honestly a bit confusing as its set to the state

I think there is an easier fix, making PR

@s77rt
Copy link
Contributor

s77rt commented May 10, 2023

@trjExpensify @mountiny I'm not referring to the main workspace chat. This is created for all. I'm referring to the other member-2-member policy chats. The ones with avatar of workspace visible under member avatars. Those only exist for the admin.

Screenshot from 2023-05-10 16-58-11

@trjExpensify
Copy link
Contributor

Ah, I see. That's still a policyExpenseChat workspace chat, it just has a different title for the admin, as it's not their own. 👍

@mountiny put a PR up with the fix for this, do you want to take a look through that?

@s77rt
Copy link
Contributor

s77rt commented May 10, 2023

@trjExpensify Right, but for members there seems to be only one policyExpenseChat. The PR looks good, just discussing some more details in Slack. Will get to that asap.

Hey I tagged you correctly twice in a row. That's an achievement 😅 🎉

@melvin-bot melvin-bot bot changed the title [Manual Requests] Fix participants on the IOUConfirmation page in the case when an admin requests money from the workspace [HOLD for payment 2023-05-23] [Manual Requests] Fix participants on the IOUConfirmation page in the case when an admin requests money from the workspace May 16, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 16, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 16, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented May 16, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.14-14 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-05-23. 🎊

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 May 16, 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:

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

@s77rt
Copy link
Contributor

s77rt commented May 17, 2023

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 23, 2023
@trjExpensify trjExpensify added the External Added to denote the issue can be worked on by a contributor label May 25, 2023
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2023-05-23] [Manual Requests] Fix participants on the IOUConfirmation page in the case when an admin requests money from the workspace [$1000] [HOLD for payment 2023-05-23] [Manual Requests] Fix participants on the IOUConfirmation page in the case when an admin requests money from the workspace May 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 25, 2023

Job added to Upwork: https://www.upwork.com/jobs/~019f72dca339218ee5

@melvin-bot
Copy link

melvin-bot bot commented May 25, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented May 25, 2023

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

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

melvin-bot bot commented May 25, 2023

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

@trjExpensify trjExpensify added Internal Requires API changes or must be handled by Expensify staff and removed 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 labels May 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 25, 2023

Current assignee @s77rt is eligible for the Internal assigner, not assigning anyone new.

@trjExpensify
Copy link
Contributor

Alrighty, @s77rt sent you an offer on this job for $1,000 for the C+ review.

@s77rt
Copy link
Contributor

s77rt commented May 25, 2023

I'm not sure if I am eligible for payment here as I didn't get to finish the reviewer checklist.

@mountiny
Copy link
Contributor Author

I think we can do a partial $250 because there was no checklist but you have helped. Does that work?

@s77rt
Copy link
Contributor

s77rt commented May 25, 2023

Sounds good!

@s77rt
Copy link
Contributor

s77rt commented May 25, 2023

@trjExpensify Can you please adjust the offer?

@trjExpensify
Copy link
Contributor

Yep, done!

@s77rt
Copy link
Contributor

s77rt commented May 25, 2023

@trjExpensify Accepted! Thanks!

@trjExpensify
Copy link
Contributor

Settled up!

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 Internal Requires API changes or must be handled by Expensify staff
Projects
None yet
Development

No branches or pull requests

5 participants