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 2024-02-26] [$500] Workspace name in Distance request flow is wrong color #33976

Closed
1 of 6 tasks
m-natarajan opened this issue Jan 4, 2024 · 55 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

@m-natarajan
Copy link

m-natarajan commented Jan 4, 2024

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: v1.4.22-0
Reproducible in staging?: yes
Reproducible in production?: yes
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: @shawnborton
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1704218630440349

Action Performed:

Create a distance request, send it to a workspace

Expected Result:

The workspace name under the "To" label should use our standard text color.

Actual Result:

The workspace name under the "To" field uses our supporting text color

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

Screen Shot 2024-01-04 at 1 29 55 PM

IMG_8478

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~015105603136672151
  • Upwork Job ID: 1742979127739854848
  • Last Price Increase: 2024-01-25
  • Automatic offers:
    • ntdiary | Reviewer | 28130781
    • Tony-MK | Contributor | 28130782
@m-natarajan m-natarajan 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 Jan 4, 2024
@melvin-bot melvin-bot bot changed the title Workspace name in Distance request flow is wrong color [$500] Workspace name in Distance request flow is wrong color Jan 4, 2024
Copy link

melvin-bot bot commented Jan 4, 2024

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

Copy link

melvin-bot bot commented Jan 4, 2024

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

Copy link

melvin-bot bot commented Jan 4, 2024

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 Jan 4, 2024
Copy link

melvin-bot bot commented Jan 4, 2024

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

@abzokhattab
Copy link
Contributor

abzokhattab commented Jan 4, 2024

Proposal

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

the workspace item under To in the confirmation list is disabled

What is the root cause of that problem?

in the confimration list, the to participants items are listed as disabled if the target participant is isOptimisticPersonalDetail (a new user)

const formattedSelectedParticipants = _.map(selectedParticipants, (participant) => ({
...participant,
isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID),
}));

and here the isOptimisticPersonalDetail is true when the accountID of the report is 0 so in this case the report of the workspace has a 0 accountID:

image

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

we need to add a check that the report is not a workspace

or in case of the worksapce we can pass the ownerAccountID instead of the accountID:

     const formattedSelectedParticipants = _.map(selectedParticipants, (participant) => {
                const accountID = ReportUtils.isPolicyExpenseChat(participant) ? participant?.ownerAccountID : participant?.accountID;
                // or
                //const accountID = participant?.accountID === 0 ? participant?.ownerAccountID : participant?.accountID;
                return {...participant, isDisabled: ReportUtils.isOptimisticPersonalDetail(accountID)};
            });

this needs to be updated also here , here and here

POC:

image

@yh-0218
Copy link
Contributor

yh-0218 commented Jan 4, 2024

Proposal

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

Workspace name in Distance request flow is wrong color

What is the root cause of that problem?

Because that workspace is disabled here
So Workspace name in Distance request flow is wrong color

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

Option1: We can make isDisabled as false for workspace.

isDisabled: participant.accountID? ReportUtils.isOptimisticPersonalDetail(participant.accountID) : false

Option2: we can keep isDisabled as true for workspace and only change disable color of workspace as default text color

What alternative solutions did you explore? (Optional)

Screenshot 2024-01-04 at 9 27 50 PM

@aim-salam
Copy link

.

@Tony-MK
Copy link
Contributor

Tony-MK commented Jan 4, 2024

Proposal

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

The workspace name in the Distance request flow is the wrong color

What is the root cause of that problem?

The following condition is true because the participant.accountID is zero.

isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID),

Therefore, the OptionRow component applies the isDisbaled style to the displayNameStyle. Hence, any workspace will look different from the rest of the items on the menu.

isDisabled ? styles.optionRowDisabled : {},

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

Just like how IOURequestStepConfirmation uses the value of participant.isPolicyExpenseChat to get the policyExpenseChat, we should replicate it in MoneyTemporaryForRefactorRequestConfirmationList for consistency.

const policyExpenseChat = _.find(participants, (participant) => participant.isPolicyExpenseChat);

Firstly, we can change the line, which brought the issue, to something similar to the code below.

isDisabled: !participant.isPolicyExpenseChat && ReportUtils.isOptimisticPersonalDetail(participant.accountID)

Secondly, to navigate back to the request page, we will have to set activeRoute as the backTo param.

Therefore, we will change the navigateToReportOrUserDetail function to this.

const activeRoute = Navigation.getActiveRouteWithoutParams();
        
if (option.accountID) {
    Navigation.navigate(ROUTES.PROFILE.getRoute(option.accountID, activeRoute));
} else if (option.reportID) {
    Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(option.reportID, activeRoute));
}

Futhermore, introduce the backTo argument in the getRoute function for ROUTES.REPORT_WITH_ID_DETAILS.

getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}`, backTo),

Finally, we need to ensure the shouldNavigateToTopMostReport prop does not cause any regressions when it is set to false.

Edit the props of the HeaderWithBackButton component like this.
Also, introduce backTo param in props.route.params.

shouldNavigateToTopMostReport={Boolean(props.route.params.backTo)}
onBackButtonPress={() => {
    Navigation.goBack(props.route.params.backTo, Boolean(props.route.params.backTo));
    Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID));
}}

What alternative solutions did you explore? (Optional)

We could also use the prop isPolicyExpenseChat, instead of using !participant.isPolicyExpenseChat. It is already passed to the MoneyTemporaryForRefactorRequestConfirmationList component by IOURequestStepConfirmation

Result
Result

@Krishna2323
Copy link
Contributor

Krishna2323 commented Jan 4, 2024

Proposal

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

the workspace item under To in the confirmation list is disabled

What is the root cause of that problem?

Because of the check below we set isDisabled to false, the function only works with the personal account of the user but not with workspaces, for workspaces it will always return true.

isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID),

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

We should fix isOptimisticPersonalDetail because it should return false when report is not a personal account. We can modify isOptimisticPersonalDetail function to return false if accountID is a falsy value. This way isOptimisticPersonalDetail will work in every case. if we don't want to use !accountID we can use isPolicyExpenseChat instead. If we want to use isPolicyExpenseChat then we need to also pass reportId to isOptimisticPersonalDetail and then get the report using getReport or by searching allReports and pass the report to isPolicyExpenseChat.

// Option 1: Return false if accountID is a falsy value.
function isOptimisticPersonalDetail(accountID: number): boolean {
    if (!accountID) {
        return false;
    }
    return isEmptyObject(allPersonalDetails?.[accountID]) || !!allPersonalDetails?.[accountID]?.isOptimisticPersonalDetail;
}


// Option 2: Return false if isPolicyExpenseChat is true.
function isOptimisticPersonalDetail(accountID: number, reportId: number): boolean {
    const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportId}`] ?? null;
    if (isPolicyExpenseChat(report)) {
        return false;
    }
    return isEmptyObject(allPersonalDetails?.[accountID]) || !!allPersonalDetails?.[accountID]?.isOptimisticPersonalDetail;
}

We already have functions related to personal account details where we return early if accountId is a falsy value.

App/src/libs/ReportUtils.ts

Lines 1475 to 1478 in 6fad557

function getDisplayNameForParticipant(accountID?: number, shouldUseShortForm = false, shouldFallbackToHidden = true): string | undefined {
if (!accountID) {
return '';
}

App/src/libs/ReportUtils.ts

Lines 1452 to 1455 in 6fad557

function getPersonalDetailsForAccountID(accountID: number): Partial<PersonalDetails> {
if (!accountID) {
return {};
}

Option 2

If we don't want to make workspace name appear disabled in any case then we can just remove the isDisabled property from both places.

Result

@shawnborton
Copy link
Contributor

Yeah, something to consider is that I don't think we need to make the workspace name appear disabled.

@ntdiary
Copy link
Contributor

ntdiary commented Jan 5, 2024

Will review over the weekend.

@melvin-bot melvin-bot bot added the Overdue label Jan 8, 2024
@ntdiary
Copy link
Contributor

ntdiary commented Jan 8, 2024

All proposals have been reviewed.

So far, I lean towards @Tony-MK's proposal, using policyExpenseChat as a condition looks appropriate and clear.
Additionally, if we want to allow navigating from the confirm page to the workspace detail page, then we also need to support the ability to return to the confirmation page when clicking the back button in the detail page. :)


@abzokhattab's proposal does not explicitly state how to check if the report is not a workspace.

The condition in @yh-0218's proposal is not as easy to understand as policyExpenseChat.

As for @Krishna2323's proposal, I feel it's unnecessary to modify the logic of ReportUtils.isOptimisticPersonalDetail, because it's also used in other components, which may introduce duplicate checks.

@melvin-bot melvin-bot bot removed the Overdue label Jan 8, 2024
@abzokhattab
Copy link
Contributor

abzokhattab commented Jan 8, 2024

Hi @ntdiary

@abzokhattab's #33976 (comment) does not explicitly state how to check if the report is not a workspace.

I am already mentioned in the code snippet to use ReportUtils.isPolicyExpenseChat(participant)

                const accountID = ReportUtils.isPolicyExpenseChat(participant) ? participant?.ownerAccountID : participant?.accountID;

this will give the accountID of the ownerAccountIDto the isOptimisticPersonalDetail as input in case the report is a workspace .. this way if the ownerAccountID is not 0 then it means it's not an optimisticPersonalDetail and wont be disabled .. this is just a safe guard so that whenever the ownerAccountID is zero it means that the workspace is anoptimisticPersonalDetail and thus can be disabled.

for your information here is the isPolicyExpenseChat function... it returns this condition:

App/src/libs/ReportUtils.ts

Lines 704 to 706 in 8aec07c

function isPolicyExpenseChat(report: OnyxEntry<Report>): boolean {
return getChatType(report) === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT || (report?.isPolicyExpenseChat ?? false);
}

last thing: please also keep mind that this needs to be updated in mutliple locations as i am mentioning in my proposal

@abzokhattab
Copy link
Contributor

@ntdiary as for the navigation issue we should add an optional backTo param in the REPORT_WITH_ID_DETAILS route
similar to the profile route

then we add this new new backTo param to the navigateToReportOrUserDetail
like this:

Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(option.reportID,activeRoute));

Thanks

@Krishna2323
Copy link
Contributor

@ntdiary, the logic for isOptimisticPersonalDetail is currently wrong and IMO its the root cause because in code below allPersonalDetails?.[accountID] is undefined & !!allPersonalDetails?.[accountID]?.isOptimisticPersonalDetail is false. We get true due to isEmptyObject function because it uses a empty object when value passed to it is undefined. The function name itself suggests that isOptimisticPersonalDetail is for only personal account details check and it should return false when allPersonalDetails?.[accountID] is undefined.

Also I don't think it will cause any regression.

return isEmptyObject(allPersonalDetails?.[accountID]) || !!allPersonalDetails?.[accountID]?.isOptimisticPersonalDetail;

@Tony-MK
Copy link
Contributor

Tony-MK commented Jan 10, 2024

Thanks for reviewing my proposal and also for the feedback, @ntdiary.

I have retested and updated my proposal based on your comments from #33976 (comment).

It works like a charm. Thank you. 😄

@ntdiary
Copy link
Contributor

ntdiary commented Jan 10, 2024

Thanks for all the responses. So far, I still need to do some investigations to confirm there won't be any regressions when navigating back.

Copy link

melvin-bot bot commented Jan 11, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Jan 12, 2024
@JmillsExpensify
Copy link

Proposals and on-going discussion still in progress.

@melvin-bot melvin-bot bot removed the Overdue label Jan 14, 2024
@Tony-MK
Copy link
Contributor

Tony-MK commented Feb 4, 2024

Hey, @ntdiary, the PR is now ready to review.
Please let me know if you have any questions.
Thank you.

@ntdiary
Copy link
Contributor

ntdiary commented Feb 6, 2024

Hey, @ntdiary, the PR is now ready to review. Please let me know if you have any questions. Thank you.

@Tony-MK, thank you for the reminder, I took a day off yesterday and will review the PR within 24 hours. :)

@dangrous
Copy link
Contributor

dangrous commented Feb 9, 2024

How are we looking on this one @Tony-MK @ntdiary ? Looks like one outstanding question and a merge conflict now. Can we get this ready for final review / merge on Monday or Tuesday? Thanks!

@Tony-MK
Copy link
Contributor

Tony-MK commented Feb 11, 2024

@dangrous, I believe we can finalize it before Tuesday. 👍

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Feb 19, 2024
@melvin-bot melvin-bot bot changed the title [$500] Workspace name in Distance request flow is wrong color [HOLD for payment 2024-02-26] [$500] Workspace name in Distance request flow is wrong color Feb 19, 2024
Copy link

melvin-bot bot commented Feb 19, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Feb 19, 2024
Copy link

melvin-bot bot commented Feb 19, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.42-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 2024-02-26. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Feb 19, 2024

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:

  • [@ntdiary] The PR that introduced the bug has been identified. Link to the PR:
  • [@ntdiary] 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:
  • [@ntdiary] 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:
  • [@ntdiary] Determine if we should create a regression test for this bug.
  • [@ntdiary] 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.
  • [@JmillsExpensify] 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 Feb 26, 2024
@JmillsExpensify
Copy link

Alright, so circling back on this one. Payment summary as follows:

I'm not seeing any issues with regressions, so @ntdiary please fill out the BZ checklist above and we can get this checklist closed out.

Copy link

melvin-bot bot commented Feb 26, 2024

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

@ntdiary
Copy link
Contributor

ntdiary commented Feb 27, 2024

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:

Regression test steps:

  1. Log in with an account that has a workspace.
  2. Click the FAB and select Request Money.
  3. Click Manual tab and type any amount, then click Next button.
  4. Select a workspace report.
  5. Verify that the workspace name under the To fields is in our standard text color and clickable to open the details page.

BTW, I'm applying to switch to NewDot for payment, so it might be better to hold this temporarily if possible. :)

@dangrous
Copy link
Contributor

Even though it's small I think it's pretty quick to check, it would just be adding a line confirming the color to whatever existing test creates the workflow. I think it's worth adding!

If you want to do a quick test, I'm sure QA can roll it in to what they already have and simplify

@ntdiary
Copy link
Contributor

ntdiary commented Feb 28, 2024

Even though it's small I think it's pretty quick to check, it would just be adding a line confirming the color to whatever existing test creates the workflow. I think it's worth adding!

Makes sense, have updated the testing steps. 😄

@melvin-bot melvin-bot bot added the Overdue label Mar 1, 2024
@JmillsExpensify
Copy link

@ntdiary Let's use the Slack thread to align on next steps, I just commented there. I'm going to close this issue for now, though I can re-open if you need to be paid via Upwork.

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

10 participants