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

[$250] Hold is not displayed in the preview for the expense which is held #46158

Closed
1 of 6 tasks
m-natarajan opened this issue Jul 25, 2024 · 34 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 Jul 25, 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: 9.0.11-5
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: @puneetlath
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1721848036803009

Action Performed:

  1. Submit a report with 2 expenses and with a violation
  2. Sign in as a approver
  3. Open the report
  4. Put the expense on Hold which has violation
  5. Look at the expense preview

Expected Result:

Preview should show "Hold"

Actual Result:

Violation error only appears. Hold should take higher priority

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

Recording.382.mp4

image (8)

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01081754863788f760
  • Upwork Job ID: 1819385736069367085
  • Last Price Increase: 2024-08-16
  • Automatic offers:
    • shubham1206agra | Reviewer | 103593386
Issue OwnerCurrent Issue Owner: @dylanexpensify
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 25, 2024
Copy link

melvin-bot bot commented Jul 25, 2024

Triggered auto assignment to @dylanexpensify (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.

@dominictb
Copy link
Contributor

Proposal

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

Violation error only appears. Hold should take higher priority

What is the root cause of that problem?

We always display violation message or error message in:

if (violations?.[0]) {
const violationMessage = ViolationsUtils.getViolationTranslation(violations[0], translate);
const violationsCount = violations.filter((v) => v.type === CONST.VIOLATION_TYPES.VIOLATION).length;
const isTooLong = violationsCount > 1 || violationMessage.length > 15;
const hasViolationsAndFieldErrors = violationsCount > 0 && hasFieldErrors;
return `${message} ${CONST.DOT_SEPARATOR} ${isTooLong || hasViolationsAndFieldErrors ? translate('violations.reviewRequired') : violationMessage}`;
}
if (hasFieldErrors) {
const isMerchantMissing = TransactionUtils.isMerchantMissing(transaction);
const isAmountMissing = TransactionUtils.isAmountMissing(transaction);
if (isAmountMissing && isMerchantMissing) {
message += ` ${CONST.DOT_SEPARATOR} ${translate('violations.reviewRequired')}`;
} else if (isAmountMissing) {
message += ` ${CONST.DOT_SEPARATOR} ${translate('iou.missingAmount')}`;
} else if (isMerchantMissing) {
message += ` ${CONST.DOT_SEPARATOR} ${translate('iou.missingMerchant')}`;
}
return message;
}
if (shouldShowHoldMessage) {
message += ` ${CONST.DOT_SEPARATOR} ${translate('violations.hold')}`;
}

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

Should use:

+if (violations?.[0] && !shouldShowHoldMessage) { // Can use violations?.[0] && !isOnHold
                const violationMessage = ViolationsUtils.getViolationTranslation(violations[0], translate);
                const violationsCount = violations.filter((v) => v.type === CONST.VIOLATION_TYPES.VIOLATION).length;
                const isTooLong = violationsCount > 1 || violationMessage.length > 15;
                const hasViolationsAndFieldErrors = violationsCount > 0 && hasFieldErrors;

                return `${message} ${CONST.DOT_SEPARATOR} ${isTooLong || hasViolationsAndFieldErrors ? translate('violations.reviewRequired') : violationMessage}`;
            }
          if (hasFieldErrors) {
                const isMerchantMissing = TransactionUtils.isMerchantMissing(transaction);
                const isAmountMissing = TransactionUtils.isAmountMissing(transaction);
                if (isAmountMissing && isMerchantMissing) {
                    message += ` ${CONST.DOT_SEPARATOR} ${translate('violations.reviewRequired')}`;
                } else if (isAmountMissing) {
                    message += ` ${CONST.DOT_SEPARATOR} ${translate('iou.missingAmount')}`;
                } else if (isMerchantMissing) {
                    message += ` ${CONST.DOT_SEPARATOR} ${translate('iou.missingMerchant')}`;
                }
                return message;
            }
            if (shouldShowHoldMessage) {
                message += ` ${CONST.DOT_SEPARATOR} ${translate('violations.hold')}`;
            }

We can consider applying the same to hasFieldErrors condition.

@bernhardoj
Copy link
Contributor

Proposal

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

Hold error message isn't prioritized to be displayed.

What is the root cause of that problem?

This is actually the same issue as #44509. However, the selected solution doesn't prioritize hold, but prioritize violation type of violation. I also posted a proposal there to prioritize the hold, so I'm gonna copy and update it here a little bit since we also want to prioritize hold over review required when there is too many violations.

When showing the violation, we only take the first violation.

if (shouldShowRBR && transaction) {
const violations = TransactionUtils.getTransactionViolations(transaction.transactionID, transactionViolations)?.sort((a) =>
a.type === CONST.VIOLATION_TYPES.VIOLATION ? -1 : 0,
);
if (violations?.[0]) {
const violationMessage = ViolationsUtils.getViolationTranslation(violations[0], translate);
const violationsCount = violations.filter((v) => v.type === CONST.VIOLATION_TYPES.VIOLATION).length;
const isTooLong = violationsCount > 1 || violationMessage.length > 15;
const hasViolationsAndFieldErrors = violationsCount > 0 && hasFieldErrors;
return `${message} ${CONST.DOT_SEPARATOR} ${isTooLong || hasViolationsAndFieldErrors ? translate('violations.reviewRequired') : violationMessage}`;
}

We previously prioritized hold in this PR, but was reverted because it caused double Hold to show up. It's because we append the violation message (that contains hold) with another hold text. But it's not guaranteed that the hold violation is always at the first item of the violations.

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

If we want the hold to be prioritized over other violations, including Review required, then we can move this condition higher in the block.

if (shouldShowHoldMessage) {
message += ` ${CONST.DOT_SEPARATOR} ${translate('violations.hold')}`;
}

if (shouldShowHoldMessage) return hold message
if (violations[0]) ...
...

Last, we can "revert" #45325 because we fix it differently here.

@melvin-bot melvin-bot bot added the Overdue label Jul 29, 2024
Copy link

melvin-bot bot commented Jul 30, 2024

@dylanexpensify Huh... This is 4 days overdue. Who can take care of this?

Copy link

melvin-bot bot commented Aug 1, 2024

@dylanexpensify 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

@trjExpensify trjExpensify added the External Added to denote the issue can be worked on by a contributor label Aug 2, 2024
@melvin-bot melvin-bot bot changed the title Hold is not displayed in the preview for the expense which is held [$250] Hold is not displayed in the preview for the expense which is held Aug 2, 2024
Copy link

melvin-bot bot commented Aug 2, 2024

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

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

melvin-bot bot commented Aug 2, 2024

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

Copy link

melvin-bot bot commented Aug 5, 2024

@shubham1206agra, @dylanexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Aug 5, 2024
@shubham1206agra
Copy link
Contributor

Last, we can "revert" #45325 because we fix it differently here.

@bernhardoj Can you give a proper solution here?
Thanks

@melvin-bot melvin-bot bot removed the Overdue label Aug 7, 2024
@bernhardoj
Copy link
Contributor

Last, we can "revert" #45325 because we fix it differently here.

@bernhardoj Can you give a proper solution here?

Sorry, I don't get what do you mean by proper solution of the revert. Can you clarify it?

@shubham1206agra
Copy link
Contributor

Sorry, I don't get what do you mean by proper solution of the revert. Can you clarify it?

@bernhardoj After reverting PR, what will be the solution to fix this issue?

@bernhardoj
Copy link
Contributor

This one
image

The current condition looks like this:

if (violations?.[0]) {
const violationMessage = ViolationsUtils.getViolationTranslation(violations[0], translate);
const violationsCount = violations.filter((v) => v.type === CONST.VIOLATION_TYPES.VIOLATION).length;
const isTooLong = violationsCount > 1 || violationMessage.length > 15;
const hasViolationsAndFieldErrors = violationsCount > 0 && hasFieldErrors;
return `${message} ${CONST.DOT_SEPARATOR} ${isTooLong || hasViolationsAndFieldErrors ? translate('violations.reviewRequired') : violationMessage}`;
}
if (hasFieldErrors) {
const isMerchantMissing = TransactionUtils.isMerchantMissing(transaction);
const isAmountMissing = TransactionUtils.isAmountMissing(transaction);
if (isAmountMissing && isMerchantMissing) {
message += ` ${CONST.DOT_SEPARATOR} ${translate('violations.reviewRequired')}`;
} else if (isAmountMissing) {
message += ` ${CONST.DOT_SEPARATOR} ${translate('iou.missingAmount')}`;
} else if (isMerchantMissing) {
message += ` ${CONST.DOT_SEPARATOR} ${translate('iou.missingMerchant')}`;
}
return message;
}
if (shouldShowHoldMessage) {
message += ` ${CONST.DOT_SEPARATOR} ${translate('violations.hold')}`;
}

The solution will update it to:

if (shouldShowHoldMessage) return `${message} ${CONST.DOT_SEPARATOR} ${translate('violations.hold')}`;
if (violations[0]) ...
if (hasFieldErrors) ...

Copy link

melvin-bot bot commented Aug 9, 2024

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

@shubham1206agra
Copy link
Contributor

Lets go with @bernhardoj's proposal

🎀👀🎀 C+ reviewed

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

melvin-bot bot commented Aug 19, 2024

📣 @shubham1206agra 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot melvin-bot bot removed the Overdue label Aug 19, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Aug 20, 2024
@bernhardoj
Copy link
Contributor

PR is ready

cc: @shubham1206agra

@dylanexpensify
Copy link
Contributor

Woot!

@dylanexpensify
Copy link
Contributor

merged!

@shubham1206agra
Copy link
Contributor

@dylanexpensify Can you add labels for payment?

@dylanexpensify dylanexpensify added Awaiting Payment Auto-added when associated PR is deployed to production and removed Reviewing Has a PR in review labels Sep 10, 2024
@dylanexpensify
Copy link
Contributor

pending prod deploy

@shubham1206agra
Copy link
Contributor

@dylanexpensify This was deployed to prod 2 weeks ago

@roryabraham
Copy link
Contributor

Sorry for the confusion @dylanexpensify. I can confirm this was deployed to prod on 2024-08-28

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Sep 17, 2024
@dylanexpensify
Copy link
Contributor

Payment summary:

Contributor: @bernhardoj $250
Contributor+: @shubham1206agra $250

Please apply/request!

@dylanexpensify
Copy link
Contributor

@shubham1206agra please accept offer! 🙇‍♂️

@dylanexpensify
Copy link
Contributor

@bernhardoj please apply to job! 🙇‍♂️

@shubham1206agra
Copy link
Contributor

@dylanexpensify Offer accepted

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

@melvin-bot melvin-bot bot added the Overdue label Sep 20, 2024
@shubham1206agra
Copy link
Contributor

@dylanexpensify Bump here

@dylanexpensify
Copy link
Contributor

done!

@github-project-automation github-project-automation bot moved this from Polish to Done in [#whatsnext] #expense Sep 23, 2024
@melvin-bot melvin-bot bot removed the Overdue label Sep 23, 2024
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
Status: Done
Development

No branches or pull requests

8 participants