App icon indicating copy to clipboard operation
App copied to clipboard

[$250] IOU - Copied link URL includes "Undefined"

Open izarutskaya opened this issue 9 months ago โ€ข 7 comments

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
  • [x] MacOS: Chrome / Safari
  • [ ] MacOS: Desktop

Screenshots/Videos

https://github.com/Expensify/App/assets/115492554/3fa41282-c99f-4aa4-aa93-6d2dd347ad6a

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-04-28

izarutskaya avatar Apr 26 '24 11:04 izarutskaya

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.

melvin-bot[bot] avatar Apr 26 '24 11:04 melvin-bot[bot]

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

izarutskaya avatar Apr 26 '24 11:04 izarutskaya

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

https://github.com/Expensify/App/blob/035adb890e559f287368b75f8cbe138c20e3f73a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx#L398-L403

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:

https://github.com/Expensify/App/assets/12425932/36d54266-a6f7-417a-b97a-9c51d7d3f542

dragnoir avatar Apr 26 '24 17:04 dragnoir

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:

https://github.com/Expensify/App/blob/2d887588583e87e3f1cb9e29352f2399b9813ff6/src/libs/ReportUtils.ts#L5277-L5279

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:

https://github.com/Expensify/App/blob/d3eeff38c7d8bf1d576b7f3faca6aac06fbd6c06/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx#L304

https://github.com/Expensify/App/blob/2d887588583e87e3f1cb9e29352f2399b9813ff6/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx#L134

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

We should prioritize the isThreadFirstChat check:

https://github.com/Expensify/App/blob/2d887588583e87e3f1cb9e29352f2399b9813ff6/src/libs/ReportUtils.ts#L5277-L5282

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:

https://github.com/Expensify/App/blob/fa29a354df9be559c2e5008523562c7384fb2aeb/src/libs/ReportUtils.ts#L1146

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

gijoe0295 avatar Apr 26 '24 21:04 gijoe0295

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

melvin-bot[bot] avatar Apr 28 '24 09:04 melvin-bot[bot]

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

melvin-bot[bot] avatar Apr 28 '24 09:04 melvin-bot[bot]

This feels like low priority / polish for vip-vsb

laurenreidexpensify avatar Apr 28 '24 09:04 laurenreidexpensify

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

melvin-bot[bot] avatar May 01 '24 18:05 melvin-bot[bot]

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

gijoe0295 avatar May 03 '24 11:05 gijoe0295

@rojiphil bump for review ^^

laurenreidexpensify avatar May 03 '24 14:05 laurenreidexpensify

@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 avatar May 03 '24 18:05 rojiphil

And sorry for the delay in review here.

rojiphil avatar May 03 '24 18:05 rojiphil

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

gijoe0295 avatar May 03 '24 18:05 gijoe0295

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?

rojiphil avatar May 03 '24 18:05 rojiphil

@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.

gijoe0295 avatar May 03 '24 23:05 gijoe0295

@gijoe0295 Thanks for the clarifications.

rojiphil avatar May 04 '24 09:05 rojiphil

@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

rojiphil avatar May 04 '24 09:05 rojiphil

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

melvin-bot[bot] avatar May 04 '24 09:05 melvin-bot[bot]

๐Ÿ“ฃ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? ๐Ÿ’ธ

melvin-bot[bot] avatar May 05 '24 16:05 melvin-bot[bot]

@bondydaa this one is ready for review ๐Ÿ‘

laurenreidexpensify avatar May 07 '24 07:05 laurenreidexpensify

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

melvin-bot[bot] avatar May 07 '24 15:05 melvin-bot[bot]

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

melvin-bot[bot] avatar May 07 '24 15:05 melvin-bot[bot]

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

bondydaa avatar May 07 '24 15:05 bondydaa

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

laurenreidexpensify avatar May 08 '24 11:05 laurenreidexpensify

Payment Summary:

  • C+ @rojiphil $250 offer sent in upwork
  • Contributor @gijoe0295 $250 offer sent in upwork

laurenreidexpensify avatar May 29 '24 11:05 laurenreidexpensify

  • C+ @rojiphil $250 offer sent in upwork

Thanks @laurenreidexpensify. Accepted the offer

rojiphil avatar May 29 '24 12:05 rojiphil

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

laurenreidexpensify avatar May 29 '24 13:05 laurenreidexpensify

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.

rojiphil avatar May 29 '24 14:05 rojiphil