Skip to content

[$500] mWeb/Chrome - IOU-Receiver of Send money is shown TBD for a second #30431

Closed

Description

@izarutskaya

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: 1.3.91-6

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

Expensify/Expensify Issue URL:

Issue reported by: Applause-Internal Team

Slack conversation: @

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. Tap on a 1:1 report of user A and User B in 2 devices
  3. Tap plus icon to select Send money as User A
  4. Enter an amount
  5. Tap next
  6. Tap Pay elsewhere
  7. Note in user B 1:1 page, TBD displayed for a second and them amount with green tick mark displayed

Expected Result:

When user A sends money to user B and paid elsewhere, in User B conversation page, TBD must not be shown before amount paid with green tick mark displayed.

Actual Result:

When user A sends money to user B and paid elsewhere, in User B conversation page, TBD appears for an second before amount paid with green tick mark displayed.

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

Android: Native
Android: mWeb Chrome
Bug6251551_1698313538896.send_and_paid.mp4
Bug6251551_1698313638741.tbd_receiver_of_send.mp4
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b75010b5fae71d08
  • Upwork Job ID: 1717511701685063680
  • Last Price Increase: 2024-01-17

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 26, 2023
  2. changed the title [-]mWeb/Chrome - IOU-Receiver of Send money is shown TBD for a second[/-] [+][$500] mWeb/Chrome - IOU-Receiver of Send money is shown TBD for a second[/+] on Oct 26, 2023
  3. melvin-bot commented on Oct 26, 2023

    @melvin-bot
  4. melvin-bot commented on Oct 26, 2023

    @melvin-bot

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

  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 26, 2023
  6. melvin-bot commented on Oct 26, 2023

    @melvin-bot

    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
  7. melvin-bot commented on Oct 26, 2023

    @melvin-bot

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

  8. paultsimura commented on Oct 26, 2023

    @paultsimura
    Contributor

    Proposal

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

    When a user receives money, the report preview displays "TBD" for a moment

    What is the root cause of that problem?

    The issue is that we are checking whether to show the "TBD" here:

    const hasOnlyDistanceRequests = ReportUtils.hasOnlyDistanceRequestTransactions(props.iouReportID);

    if (hasOnlyDistanceRequests) {
    return props.translate('common.tbd');
    }

    The logic to determine this variable is the following:

    App/src/libs/ReportUtils.js

    Lines 669 to 678 in 950f37a

    /**
    * Checks whether all the transactions linked to the IOU report are of the Distance Request type
    *
    * @param {string|null} iouReportID
    * @returns {boolean}
    */
    function hasOnlyDistanceRequestTransactions(iouReportID) {
    const allTransactions = TransactionUtils.getAllReportTransactions(iouReportID);
    return _.all(allTransactions, (transaction) => TransactionUtils.isDistanceRequest(transaction));
    }

    It returns true if the transactions list is empty.

    When the user receives "Send money", this IOU report doesn't contain the transactions.

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

    We should modify the ReportUtils.hasOnlyDistanceRequestTransactions function to return false if there are no transactions in the report:

    function hasOnlyDistanceRequestTransactions(iouReportID) {
        const allTransactions = TransactionUtils.getAllReportTransactions(iouReportID);
        return !!allTransactions.length && _.all(allTransactions, (transaction) => TransactionUtils.isDistanceRequest(transaction));
    }

    However, the report preview will still flicker, just with different data: it'll show "owes: {amount}" which will be changed to "{user} paid: {amount}" on the following re-render.

    I believe we are facing the Onyx updates order issue here once again #28737 (comment)

    The Pusher sends data in the correct order: first, the IOU Report and the Transaction, and only then – the REPORTPREVIEW report action. But the ReportView component is rendered with the reversed data order: first, the reportAction is created, and only then – the IOU report is fetched.

    What alternative solutions did you explore? (Optional)

  9. samilabud commented on Oct 26, 2023

    @samilabud
    Contributor

    Proposal

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

    mWeb/Chrome - IOU-Receiver of Send money is shown TBD for a second

    What is the root cause of that problem?

    This is happening in all platforms but only can be appreciated in the slower ones. What occurs here is we are calling getDisplayAmount on every render and not when we need it, that's why we can see the TBD for a second before another render updates the text. Additionally, huge rerender causes slowness in the chat performance.

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

    The first thing should be to import useState and useEffect to control the huge rerendering in ReportPreview component (
    https://github.com/Expensify/App/blob/55c936652796ddfee944c86b6642ab821bdcf209/src/components/ReportActionItem/ReportPreview.js)
    Then we can include the next changes:
    const [displayAmount, setDisplayAmount] = useState();

    useEffect(()=>{
            const getDisplayAmount = () => {
                if (totalDisplaySpend) {
                    return CurrencyUtils.convertToDisplayString(totalDisplaySpend, props.iouReport.currency);
                }
                if (isScanning) {
                    return props.translate('iou.receiptScanning');
                }
                if (hasOnlyDistanceRequests) {
                    return props.translate('common.tbd');
                }
        
                // If iouReport is not available, get amount from the action message (Ex: "Domain20821's Workspace owes $33.00" or "paid ₫60" or "paid -₫60 elsewhere")
                let displayAmount = '';
                const actionMessage = lodashGet(props.action, ['message', 0, 'text'], '');
                const splits = actionMessage.split(' ');
                for (let i = 0; i < splits.length; i++) {
                    if (/\d/.test(splits[i])) {
                        displayAmount = splits[i];
                    }
                }
                return displayAmount;
            };
            setDisplayAmount(getDisplayAmount());
        },[totalDisplaySpend, isScanning, hasOnlyDistanceRequests])
    

    And finally, use the const previously declared to show the amount correctly:

    {displayAmount && (
                                <View style={styles.flexRow}>
                                    <View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
                                        <Text style={styles.textHeadline}>{displayAmount}</Text>
                                        {ReportUtils.isSettled(props.iouReportID) && (
                                            <View style={styles.defaultCheckmarkWrapper}>
                                                <Icon
                                                    src={Expensicons.Checkmark}
                                                    fill={themeColors.iconSuccessFill}
                                                />
                                            </View>
                                        )}
                                    </View>
                                </View>
                            )}
    
    

    This is what is happening currently:

    Current.Behavior.mp4
    Current behaviot TBD capture

    This is after changes:

    After.changes.mp4
  10. narefyev91 commented on Oct 27, 2023

    @narefyev91
    Contributor

    @paultsimura does correct order fix for onyx will automatically fix current issue?

  11. paultsimura commented on Oct 27, 2023

    @paultsimura
    Contributor

    @paultsimura does correct order fix for onyx will automatically fix current issue?

    It should, because the iouReport will be present at the moment the reportAction is added, and the flickering currently happens because the iouReport is missing.

    However, that Onyx issue has been open for a while, and I'm curious if we'll have any progress on it anytime soon...

  12. 27 remaining items

  13. mallenexpensify commented on Jan 3, 2024

    @mallenexpensify
    Contributor
  14. changed the title [-][HOLD App #30219] [$500] mWeb/Chrome - IOU-Receiver of Send money is shown TBD for a second[/-] [+][$500] mWeb/Chrome - IOU-Receiver of Send money is shown TBD for a second[/+] on Jan 17, 2024
  15. mallenexpensify commented on Jan 17, 2024

    @mallenexpensify
    Contributor

    Off hold, #30219 hit production

    @izarutskaya can you retest? I don't have an android phone handy to test with. Thx

  16. melvin-bot commented on Jan 17, 2024

    @melvin-bot

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

  17. hayata-suenaga commented on Jan 18, 2024

    @hayata-suenaga
    Contributor

    I asked in the QA channel to get somebody test this

  18. kbecciv commented on Jan 18, 2024

    @kbecciv

    Issue is fixed, build 1.4.27.0

    az_recorder_20240118_222505.mp4
  19. hayata-suenaga commented on Jan 18, 2024

    @hayata-suenaga
    Contributor

    since this was fixed, I'm closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions