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

[$500] The updated amount is not copied to clipboard. #26664

Closed
6 tasks
kavimuru opened this issue Sep 4, 2023 · 25 comments
Closed
6 tasks

[$500] The updated amount is not copied to clipboard. #26664

kavimuru opened this issue Sep 4, 2023 · 25 comments
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 Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@kavimuru
Copy link

kavimuru commented Sep 4, 2023

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


Action Performed:

  1. Request money
  2. Open IOU and change amount.
  3. Click on Copy to clipboard on IOU item.
  4. Paste to chat.

Expected Result:

The updated amount should appear.

Actual Result:

The updated amount does not appear.

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

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.62-4
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

2023-08-25_20-57-31.mp4
bandicam.2023-09-04.20-08-17-147.mp4

Expensify/Expensify Issue URL:
Issue reported by: @oleksandr-pantsyr
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1692986644530329

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012d2ba9ac8db0e8b1
  • Upwork Job ID: 1699071512490926080
  • Last Price Increase: 2023-09-05
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 4, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 4, 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

@paultsimura
Copy link
Contributor

paultsimura commented Sep 4, 2023

Proposal

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

The modified request amount is not copied to the clipboard.

What is the root cause of that problem?

On updating the money request, we only update the transaction and create a new updatedReportAction in the thread

function editMoneyRequest(transactionID, transactionThreadReportID, transactionChanges) {

image

The message on the original reportAction is not updated. While the copyToClipboard action copies the action's message here:

const messageHtml = isTaskAction ? lodashGet(originalMessage, 'html', '') : lodashGet(message, 'html', '');

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

  1. Pass parentReportAction as another parameter to IOU.editMoneyRequest here:
    function editMoneyRequest(transactionChanges) {
    IOU.editMoneyRequest(transaction.transactionID, report.reportID, transactionChanges);
    Navigation.dismissModal();
    }
  2. In the IOU.editMoneyRequest, along with 2 existing merge requests, add the following:
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`,
            value: {
                [parentReportAction.reportActionID]: {
                    message: ReportUtils.getIOUReportActionMessage(
                        parentReportAction.originalMessage.IOUReportID,
                        parentReportAction.originalMessage.type,
                        updatedTransaction.modifiedAmount,
                        updatedTransaction.comment.comment,
                        updatedTransaction.modifiedCurrency,
                    ),
                },
            },
        },

This will update the message of the original reportAction.

Note: This apparently requires updating the EditMoneyRequest API handler on BE as well, because the optimistically stored message gets eventually reset to the original one.

What alternative solutions did you explore? (Optional)

@alphaboss1104
Copy link
Contributor

This is BE issue. Because when we send the editMoneyRequst request to BE, it doesn't return any value to set the MoneyRequestPreview 's reportAction.
image

As I see @paultsimura 's opinion for root cause is correct but his solution isn't enough.
In his solution he merged only message but we should merge all necessary details.

@paultsimura
Copy link
Contributor

My proposal fixes the clipboard issue, right what is described in the ticket.

However, I'd like to understand what is the "all necessary details" - from my understanding, the details like currency, description, amount are stored in the originalMessage, which should not be modified. And all of that data can (and should) be fetched from the transaction.

As I see @paultsimura 's opinion for root cause is correct but his solution isn't enough.

In his solution he merged only message but we should merge all necessary details.

@zanyrenney
Copy link
Contributor

Yep, this is reproducible, adding the external label.

@zanyrenney zanyrenney added the External Added to denote the issue can be worked on by a contributor label Sep 5, 2023
@melvin-bot melvin-bot bot changed the title The updated amount is not copied to clipboard. [$500] The updated amount is not copied to clipboard. Sep 5, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 5, 2023

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

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

melvin-bot bot commented Sep 5, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 5, 2023

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

@parasharrajat
Copy link
Member

@parasharrajat
Copy link
Member

So it seems that it should have been fixed in #24630.

@oleksandr-pantsyr
Copy link

Hi @parasharrajat thank you for investigating.
But my issue is different from your issue. your issue is that the IOU comment is not copied.
But my issue even if IOU comment is copied, it does not reflect the updated amount.
I don't think my issue will be fixed even if #24630 is fixed.

@parasharrajat
Copy link
Member

OK, I see that it is different from #24569.

Both proposals are wrong. you are looking at the old reportaction but we are forgetting that it is an action that won't change. Instead, we add more modified actions for details being updated.

So if we want to copy the exact message as previewed, then the message needs to be formatted from data instead of using static values from actions.

@mountiny because you worked on it earlier. What do you think about this issue?

@mountiny
Copy link
Contributor

mountiny commented Sep 7, 2023

@parasharrajat thats correct the MoneyRequestAction component is basically just a view for the Transaction which is assocaited with ti and the link is in the message.IOUTransactionID field, this way you can pull the transaction object and get the data you want

@BhuvaneshPatil
Copy link
Contributor

BhuvaneshPatil commented Sep 7, 2023

Proposal

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

The updated amount is not copied to clipboard

What is the root cause of that problem?

We are getting the copied text from html property but if we debug that, html property shows the previous value
Screenshot 2023-09-07 at 9 55 17 PM

That's why we are not getting updated value.

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

To get the value of text correctly we should notice how it's being done in MoneyRequestPreview.
We use getTransactionDetails() method for getting required fields.

  • amount
  • currency
  • comment
  • merchant
    from transaction. We have transactionId from originalMessage
Screenshot 2023-09-07 at 9 59 56 PM

We can add new check for checking if the action is IOU or not (which is in case of money request preview)
And handle that separately.

More concisely -

  • Create a new method that will give us final string in case of IOU in ContextMenuAction

There is another caveat to this, handling in case of description is present.

We need confirmation from expensify how to handle that, current behaviour is requested ₹343.00 for abdasd

function will look something like this (needs some polishing)

function getTransactionMessage(reportAction) {
    const originalMessage = _.get(reportAction, 'originalMessage', {});
    // get transactionId
    const transactionId = _.get(originalMessage, 'IOUTransactionID', 0);
    const transaction = getTransaction(transactionId);
    const reportID = _.get(transaction, 'reportID');
    const report = lodashGet(allReports, `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {}) || {};
    const details = {
        created: getCreated(transaction),
        amount: getAmount(transaction, lodashGet(report, 'type') === CONST.REPORT.TYPE.EXPENSE),
        currency: getCurrency(transaction),
        comment: getDescription(transaction),
        merchant: getMerchant(transaction),
    };

    return `requested ${CurrencyUtils.convertToDisplayString(details.amount, details.currency)}${details.comment && ` for ${details.comment}`}`;
}
else if (isIOUAction && _.get(originalMessage, 'type', '') === CONST.IOU.REPORT_ACTION_TYPE.CREATE) {
                    const str = TransactionUtils.getTransactionMessage(reportAction);
                    Clipboard.setString(str);
                }

result -

Screen.Recording.2023-09-07.at.11.40.25.PM.mov

What alternative solutions did you explore? (Optional)

@parasharrajat
Copy link
Member

parasharrajat commented Sep 7, 2023

@BhuvaneshPatil Thanks for the proposal.

There are a few types of IOU in the App.

 MONEY_REQUEST_TYPE: {
            SEND: 'send',
            SPLIT: 'split',
            REQUEST: 'request',
        },

Now, the function needs to give a properly formatted string. Can you please lay out the logic of the function on how will you create the message?

Hint: Try creating all types of requests and observe them, modify your function to fit in. Then edit these requests and observe again.

You will be able to get the messages used from original message strings for all types. Normally, the same is used in LHN as the last message text.

@BhuvaneshPatil
Copy link
Contributor

BhuvaneshPatil commented Sep 7, 2023

sure @parasharrajat

  • For split bill, using the html will be option, we can't change the amount and description
  • I can't use send money currently, shows not found page when I try

We can add another check in the context menu action.
ex -

if(isIOU && !isSplitBill){
//
}

@paultsimura
Copy link
Contributor

paultsimura commented Sep 7, 2023

Proposal

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

The modified request amount is not copied to the clipboard.

What is the root cause of that problem?

On copy-to-clipboard action, we copy only the static reportAction.message instead of building it dynamically from transaction.

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

onPress: (closePopover, {reportAction, selection}) => {

To the chain of if/else, add the following logic:

} else if (ReportActionsUtils.isMoneyRequestAction(reportAction)) {
    const transaction = getTransaction(originalMessage.IOUTransactionID);
    const {
        amount,
        currency,
        comment
    } = ReportUtils.getTransactionDetails(transaction);

    const iouMessage = ReportUtils.getIOUReportActionMessage(
        transaction.reportID,
        originalMessage.type,
        amount,
        comment,
        currency,
   );

    const iouMessageHtml = lodashGet(_.last(iouMessage), 'html', '');
    Clipboard.setString(iouMessageHtml);
}

This ReportUtils.getIOUReportActionMessage method is used for building the initial message, so using it here should do the thing. Also, my solution is versatile and supports any type of IOU report action along with the request description updates (which is currently not copied to clipboard either).

The only possible improvement I see is to move this to a separate function inside the ReportUtils.
Additionally, I would recommend modifying the ReportUtils.getIOUReportActionMessage function in order to support localization instead of using hardcoded strings.

Results of the same request being edited:
image
image

What alternative solutions did you explore? (Optional)

@parasharrajat
Copy link
Member

parasharrajat commented Sep 7, 2023

Thanks, I am discussing this issue as a possible regression.

@BhuvaneshPatil
Copy link
Contributor

Updated proposal

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

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

@pecanoro
Copy link
Contributor

I am going to close this issue because it's basically the same root cause as #26571 and this was created after.

@BhuvaneshPatil
Copy link
Contributor

@pecanoro This issue is about money request and the other one is about task and the solution is totally different

@BhuvaneshPatil
Copy link
Contributor

BhuvaneshPatil commented Sep 11, 2023

The issue #26571 is possible dupe of #26753

Please confirm at your end

@pecanoro
Copy link
Contributor

@BhuvaneshPatil It's a regression for the same PR, so we need to solve it in a single PR.

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 Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

9 participants