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-05-29][$250] IOU - Copied link URL includes "Undefined" #41084

Closed
1 of 6 tasks
izarutskaya opened this issue Apr 26, 2024 · 28 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review

Comments

@izarutskaya
Copy link

izarutskaya commented Apr 26, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.66-2
Reproducible in staging?: Y
Reproducible in production?: Y
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

  1. Navigate to staging.new.expensify.com
  2. Send an IOU to a user
  3. Open the expense report and send a comment
  4. Reply in thread to the sent comment on step 3
  5. Hover over the IOU preview component and click on copy link
  6. Paste the copied link elsewhere

Expected Result:

The copied URL doesn't include "Undefined"

Actual Result:

The copied URL includes "Undefined" at the end

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

Bug6462644_1714123878533.bandicam_2024-04-26_12-26-46-976.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a65eb92968b7e037
  • Upwork Job ID: 1784516119574372352
  • Last Price Increase: 2024-05-05
Issue OwnerCurrent Issue Owner: @gijoe0295
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 26, 2024
Copy link

melvin-bot bot commented Apr 26, 2024

Triggered auto assignment to @laurenreidexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@izarutskaya
Copy link
Author

We think this issue might be related to the #vip-vsb.

@dragnoir
Copy link
Contributor

dragnoir commented Apr 26, 2024

Proposal

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

Copied link URL includes "Undefined"

What is the root cause of that problem?

on context menu, the copy link menu item const reportActionID = reportAction?.reportActionID; can be undefined

onPress: (closePopover, {reportAction, reportID}) => {
Environment.getEnvironmentURL().then((environmentURL) => {
const reportActionID = reportAction?.reportActionID;
Clipboard.setString(`${environmentURL}/r/${reportID}/${reportActionID}`);
});
hideContextMenu(true, ReportActionComposeFocusManager.focus);

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

We need to check if the value reportAction?.reportActionID is available first.

const reportActionID = reportAction?.reportActionID || '';

POC:

20240426_184957.mp4

@gijoe0295
Copy link
Contributor

gijoe0295 commented Apr 26, 2024

Proposal

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

reportActionID in URL is undefined when reply an expense report's message in thread

What is the root cause of that problem?

originalReportID evaluated in ReportActionItem points to the transaction thread report, but should be the policy expense report instead:

App/src/libs/ReportUtils.ts

Lines 5277 to 5279 in 2d88758

if (transactionThreadReportID !== null) {
return Object.keys(currentReportAction ?? {}).length === 0 ? transactionThreadReportID : reportID;
}

By the early return above, we skip the isThreadFirstCheck which should be used for the report preview action in this case.

Then when we retrieved the report actions in BaseReportActionContextMenu we couldn't find the correct action because it apparently belonged to another report:

key: ({originalReportID}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`,

return reportActions[reportActionID] ?? null;

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

We should prioritize the isThreadFirstChat check:

App/src/libs/ReportUtils.ts

Lines 5277 to 5282 in 2d88758

if (transactionThreadReportID !== null) {
return Object.keys(currentReportAction ?? {}).length === 0 ? transactionThreadReportID : reportID;
}
return isThreadFirstChat(reportAction, reportID) && Object.keys(currentReportAction ?? {}).length === 0
? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.parentReportID
: reportID;

if (Object.keys(currentReportAction ?? {}).length === 0) {
    return isThreadFirstChat(reportAction, reportID) ? parentReportID : transactionThreadReportID ?? reportID;
}
return reportID;

What alternative solutions did you explore? (Optional)

Or we can just show [Deleted report] in this case, by this user couldn't copy link. That means expense reports with no expenses are deleted. To do this, we can either:

  1. Modify the isClosedExpenseReportWithNoExpenses to not include the statusNum condition. Now it should be isExpenseReportWithNoExpenses:

function isClosedExpenseReportWithNoExpenses(report: OnyxEntry<Report>): boolean {

  1. Modify the backend to set the expense report's statusNum to CLOSED (i.e. 2) when there're no expenses.

@laurenreidexpensify laurenreidexpensify added the External Added to denote the issue can be worked on by a contributor label Apr 28, 2024
@melvin-bot melvin-bot bot changed the title IOU - Copied link URL includes "Undefined" [$250] IOU - Copied link URL includes "Undefined" Apr 28, 2024
Copy link

melvin-bot bot commented Apr 28, 2024

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

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

melvin-bot bot commented Apr 28, 2024

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

@laurenreidexpensify
Copy link
Contributor

This feels like low priority / polish for vip-vsb

Copy link

melvin-bot bot commented May 1, 2024

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

@gijoe0295
Copy link
Contributor

Hi @rojiphil did you have a chance to take a look?

@laurenreidexpensify
Copy link
Contributor

@rojiphil bump for review ^^

@melvin-bot melvin-bot bot removed the Overdue label May 3, 2024
@rojiphil
Copy link
Contributor

rojiphil commented May 3, 2024

@gijoe0295 As per your proposal, the copied link will have reportActionID as that of the Report Preview action and reportID as that of the Report Preview action’s Chat Report. Is my understanding correct?

@rojiphil
Copy link
Contributor

rojiphil commented May 3, 2024

And sorry for the delay in review here.

@gijoe0295
Copy link
Contributor

gijoe0295 commented May 3, 2024

@rojiphil Yes, correct. In other words, that will link to the report preview action in the policy expense report (not the expense report currently).

@rojiphil
Copy link
Contributor

rojiphil commented May 3, 2024

Yes, correct. In other words, that will link to the report preview action in the policy expense report (not the expense report currently).

@gijoe0295 And why do you think reportID should point to the policy expense report?

@gijoe0295
Copy link
Contributor

gijoe0295 commented May 3, 2024

@rojiphil because the report preview is in the policy expense report. If it didn't point to the correct report, it would cause errors like this one, or navigate to not found page.

@rojiphil
Copy link
Contributor

rojiphil commented May 4, 2024

@gijoe0295 Thanks for the clarifications.

@rojiphil
Copy link
Contributor

rojiphil commented May 4, 2024

@gijoe0295 proposal has the correct RCA and solution.
This will also ensure Copy to clipboard to work correctly which is otherwise broken currently.
🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented May 4, 2024

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

Copy link

melvin-bot bot commented May 5, 2024

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

@laurenreidexpensify
Copy link
Contributor

@bondydaa this one is ready for review 👍

@melvin-bot melvin-bot bot removed the Overdue label May 7, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label May 7, 2024
Copy link

melvin-bot bot commented May 7, 2024

❌ There was an error making the offer to @rojiphil for the Reviewer role. The BZ member will need to manually hire the contributor.

Copy link

melvin-bot bot commented May 7, 2024

❌ There was an error making the offer to @gijoe0295 for the Contributor role. The BZ member will need to manually hire the contributor.

@bondydaa
Copy link
Contributor

bondydaa commented May 7, 2024

oh GH issues might have caused that https://www.githubstatus.com/incidents/tsrh60nkbchl

@laurenreidexpensify
Copy link
Contributor

@gijoe0295 looks like we good to go - please let us know when you expect to have a draft PR up thanks

@melvin-bot melvin-bot bot added the Overdue label May 9, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 Overdue labels May 9, 2024
@laurenreidexpensify laurenreidexpensify changed the title [$250] IOU - Copied link URL includes "Undefined" [HOLD for Payment 2024-05-29][$250] IOU - Copied link URL includes "Undefined" May 28, 2024
@laurenreidexpensify laurenreidexpensify added Daily KSv2 and removed Weekly KSv2 labels May 28, 2024
@laurenreidexpensify
Copy link
Contributor

Payment Summary:

@rojiphil
Copy link
Contributor

Thanks @laurenreidexpensify. Accepted the offer

@laurenreidexpensify
Copy link
Contributor

Payment Summary:

C+ @rojiphil $250 paid in upwork
Contributor @gijoe0295 $250 paid in upwork

@rojiphil do we need a regression test for this - please confirm steps if so, thanks

@rojiphil
Copy link
Contributor

do we need a regression test for this - please confirm steps if so, thanks

A regression test is not required as this issue occurs only in certain cases and is not high-impact. We can skip this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review
Projects
No open projects
Archived in project
Development

No branches or pull requests

6 participants