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-08-10] [$1000] Web - Workspace name is empty in request money page #23348

Closed
1 of 6 tasks
kbecciv opened this issue Jul 21, 2023 · 27 comments
Closed
1 of 6 tasks
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

@kbecciv
Copy link

kbecciv commented Jul 21, 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:

Requirement: have policy expense chat beta access and a workspace

  1. Press FAB and choose Request Money
  2. Enter any amount and press Next
  3. Search your workspace and select it as the participant
  4. Verify you are brought to the confirmation page

Expected Result:

Workspace name is shown on the confirmation page

Actual Result:

Workspace name is not shown on the confirmation page

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: 1.3.43-3
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-07-21.at.00.34.09.mov
Recording.3802.mp4

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~011f529c8226628bb0
  • Upwork Job ID: 1683692732773302272
  • 2023-07-25
  • Automatic offers:
    • s77rt | Reviewer | 25818805
    • bernhardoj | Contributor | 25818806
    • bernhardoj | Reporter | 25818807
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 21, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 21, 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

@kbecciv
Copy link
Author

kbecciv commented Jul 21, 2023

Proposal

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

Workspace name is empty on money request confirmation page

What is the root cause of that problem?

The confirmation list item is OptionRow and the title (that should show the workspace name) is retrieved from this.props.option.text. The option props data that is shown (for the workspace) on the confirmation page comes from OptionListUtils.getPolicyExpenseReportOptions.

function getPolicyExpenseReportOptions(report) {
const expenseReport = policyExpenseReports[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`];
const policyExpenseChatAvatarSource = ReportUtils.getWorkspaceAvatar(expenseReport);
return [
{
...expenseReport,
keyForList: expenseReport.policyID,
text: expenseReport.displayName,

We can see that we return text with the value from expenseReport.displayName and it's been like this for a f few months. The problem is, the displayName property does not exist on a report. This might raise a question, if it doesn't exist, why do we just see the issue now? Why it works just fine before?
Short: The answer is, this issue started to happen after this PR #21406.
Long:
Before the above PR, we can access displayName from a report object. The displayName is available because we are mutating the Onyx report object here:
_.each(reportsToDisplay, (report) => {
// Normally, the spread operator would be used here to clone the report and prevent the need to reassign the params.
// However, this code needs to be very performant to handle thousands of reports, so in the interest of speed, we're just going to disable this lint rule and add
// the reportDisplayName property to the report object directly.
// eslint-disable-next-line no-param-reassign
report.displayName = ReportUtils.getReportName(report);
// eslint-disable-next-line no-param-reassign
report.iouReportAmount = ReportUtils.getMoneyRequestTotal(report, allReportsDict);
});

We are still mutating it now, the difference is, the report object we are mutating is the cloned report. If you notice the code above, we are mutating the reportsToDisplay that is the filtered allReportsDict.
function getOrderedReportIDs(currentReportId, allReportsDict, betas, policies, priorityMode, allReportActions) {
const isInGSDMode = priorityMode === CONST.PRIORITY_MODE.GSD;
const isInDefaultMode = !isInGSDMode;
// Filter out all the reports that shouldn't be displayed
const reportsToDisplay = _.filter(allReportsDict, (report) =>
ReportUtils.shouldReportBeInOptionList(report, currentReportId, isInGSDMode, allReportsDict, betas, policies, allReportActions),
);

allReportsDict is passed from SidebarLinksData, which is the chatReports as you can see below.
const optionListItems = useMemo(() => {
const reportIDs = SidebarUtils.getOrderedReportIDs(currentReportID, chatReports, betas, policies, priorityMode, allReportActions);

chatReports comes from the Onyx with a selector.
chatReports: {
key: ONYXKEYS.COLLECTION.REPORT,
selector: chatReportSelector,
},

The selector is the one that clones the object.
const chatReportSelector = (report) =>
report && {
reportID: report.reportID,
participants: report.participants,
participantAccountIDs: report.participantAccountIDs,
hasDraft: report.hasDraft,
isPinned: report.isPinned,
errorFields: {
addWorkspaceRoom: report.errorFields && report.errorFields.addWorkspaceRoom,
},
lastMessageText: report.lastMessageText,
lastVisibleActionCreated: report.lastVisibleActionCreated,
iouReportID: report.iouReportID,
total: report.total,
hasOutstandingIOU: report.hasOutstandingIOU,
statusNum: report.statusNum,
stateNum: report.stateNum,
chatType: report.chatType,
type: report.type,
policyID: report.policyID,
visibility: report.visibility,
lastReadTime: report.lastReadTime,
// Needed for name sorting:
reportName: report.reportName,
policyName: report.policyName,
oldPolicyName: report.oldPolicyName,
// Other less obvious properites considered for sorting:
ownerAccountID: report.ownerAccountID,
currency: report.currency,
managerID: report.managerID,
// Other important less obivous properties for filtering:
parentReportActionID: report.parentReportActionID,
parentReportID: report.parentReportID,
};

Previously, reportsToDisplay comes directly from the report object, that is allReports.
let allReports;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (val) => (allReports = val),
});

That's why before the PR, mutating the report object will have an effect on every part of the app that uses the object.
So, the current code mutates the cloned object, while the previous code mutates the real object.
NOTE: even though the issue happens after #21406, I wouldn't say it's a regression, but rather we are discovering a hidden bug.

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

Never use the displayName property. We also have another issue #22128 that also avoids it now.
Instead, get the name from ReportUtils.getReportName(expenseReport).
We will use the result for both text and name inside the icons array.

@melvin-bot melvin-bot bot added the Overdue label Jul 24, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 24, 2023

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

@kadiealexander
Copy link
Contributor

Reproduced

image

@melvin-bot melvin-bot bot removed the Overdue label Jul 25, 2023
@kadiealexander kadiealexander added the External Added to denote the issue can be worked on by a contributor label Jul 25, 2023
@melvin-bot melvin-bot bot changed the title Web - Workspace name is empty in request money page [$1000] Web - Workspace name is empty in request money page Jul 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 25, 2023

Job added to Upwork: https://www.upwork.com/jobs/~011f529c8226628bb0

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

melvin-bot bot commented Jul 25, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 25, 2023

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

@s77rt
Copy link
Contributor

s77rt commented Jul 25, 2023

@bernhardoj Thanks for the proposal. Your RCA is correct and the solution looks good to me. The displayName prop is not a real prop after all (it's a client-side only). The use of ReportUtils.getReportName makes sense here. But before moving forward, can you please check if we can improve this loop, instead of assigning displayName and iouReportAmount to report we should use local variables to prevent this kind of bug.

@bernhardoj
Copy link
Contributor

Hmm, I don't know what the local variables would look like. One idea I could think of is to introduce a new object that stored both displayName and iouReportAmount.

const reports = {};
// There are a few properties that need to be calculated for the report which are used when sorting reports.
_.each(reportsToDisplay, (report) => {
    reports[report.reportID] = {
        displayName: ReportUtils.getReportName(report),
        iouReportAmount: ReportUtils.getMoneyRequestTotal(report, allReportsDict),
    }
});

and then in the sort below we can do like:

-pinnedReports = _.sortBy(pinnedReports, (report) => report.displayName.toLowerCase());
-outstandingIOUReports = lodashOrderBy(outstandingIOUReports, ['iouReportAmount', (report) => report.displayName.toLowerCase()], ['desc', 'asc']);
+pinnedReports = _.sortBy(pinnedReports, (report) => reports[report.reportID].displayName.toLowerCase());
+outstandingIOUReports = lodashOrderBy(outstandingIOUReports, [(report) => reports[report.reportID].iouReportAmount, (report) => reports[report.reportID].displayName.toLowerCase()], ['desc', 'asc']);
and so on...

haven't tested it yet.

@s77rt
Copy link
Contributor

s77rt commented Jul 26, 2023

@bernhardoj Thanks for the update. Given that getOrderedReportIDs is only called once on the cloned object let's not worry about that reassignment.

🎀 👀 🎀 C+ reviewed
Link to proposal

@melvin-bot
Copy link

melvin-bot bot commented Jul 26, 2023

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

@kadiealexander
Copy link
Contributor

@AndrewGable any thoughts here?

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

melvin-bot bot commented Jul 29, 2023

📣 @s77rt 🎉 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 Jul 29, 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 📖

@melvin-bot
Copy link

melvin-bot bot commented Jul 29, 2023

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

Offer link
Upwork job

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jul 29, 2023
@bernhardoj
Copy link
Contributor

PR is ready

cc: @s77rt

@melvin-bot
Copy link

melvin-bot bot commented Aug 1, 2023

🎯 ⚡️ Woah @s77rt / @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-29 00:12:03 Z
  • when the PR got merged: 2023-08-01 02:50:01 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 Aug 3, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Web - Workspace name is empty in request money page [HOLD for payment 2023-08-10] [$1000] Web - Workspace name is empty in request money page Aug 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 3, 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 Aug 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 3, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.49-3 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-08-10. 🎊

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 Aug 3, 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
Copy link
Contributor

s77rt commented Aug 4, 2023

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Aug 9, 2023
@kadiealexander
Copy link
Contributor

kadiealexander commented Aug 10, 2023

Payouts due:

Issue Reporter: $250 @bernhardoj
Contributor: $1000 + $500 bonus @bernhardoj
Contributor+: $1000 + $500 bonus @s77rt

Eligible for 50% #urgency bonus? Yes

Upwork job is here.

@melvin-bot melvin-bot bot removed the Overdue label Aug 10, 2023
@bernhardoj
Copy link
Contributor

I can't access the job.
image

Can you invite me to the job?

@kadiealexander
Copy link
Contributor

It's cool, we already have a contract in the works! :)

@bernhardoj
Copy link
Contributor

Ah, you're right. I didn't see that 😅. Thanks!

@kadiealexander
Copy link
Contributor

Everyone is paid 🎉 thanks for your work on this!

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

5 participants