Skip to content

[Due for payment 2025-08-01] [$250] Stop showing RTER violation on the reports page for paid transactions #65761

Closed

Description

@cead22

Problem
Currently we're showing the RTER violation on paid transactions on the report page, as you can see in the screenshot below
Image

Note that the Scanning... in the screenshot is a bug, and what I'm highlighting is

  • We're on the report page
  • The red circle and accompanying red text for the violation
  • The fact that these transactions show as paid

Solution
After discussing with product (@JmillsExpensify) we landed on showing violations on the report page, even for paid transactions, but with the exception of the RTER violation

Let's update the code that displays violations on the reports page to omit the RTER violation

Issue OwnerCurrent Issue Owner: @sakluger

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 9, 2025
  2. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 9, 2025
  3. melvin-bot commented on Jul 9, 2025

    @melvin-bot

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

  4. melvin-bot commented on Jul 9, 2025

    @melvin-bot

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

  5. Krishna2323 commented on Jul 9, 2025

    @Krishna2323
    Contributor

    Proposal

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

    Stop showing RTER violation on the reports page for paid transactions

    What is the root cause of that problem?

    • New requirement

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

    • Add a new parameter to shouldShowViolation, name it shouldShowRterForSettled and default it to true. Then update the function to only filter out the rter violation if shouldShowRterForSettled is false.
    function shouldShowViolation(iouReport: OnyxEntry<Report>, policy: OnyxEntry<Policy>, violationName: ViolationName, shouldShowRterForPaid = true): boolean {
        const isSubmitter = isCurrentUserSubmitter(iouReport?.reportID);
        const isPolicyMember = isPolicyMemberPolicyUtils(currentUserEmail, policy?.id);
        const isReportOpen = isOpenExpenseReport(iouReport);
    
        if (violationName === CONST.VIOLATIONS.AUTO_REPORTED_REJECTED_EXPENSE) {
            return isSubmitter;
        }
    
        if (violationName === CONST.VIOLATIONS.OVER_AUTO_APPROVAL_LIMIT) {
            return return isPolicyAdmin(policy) && !isSubmitter; 
        }
    
        if (violationName === CONST.VIOLATIONS.RTER) {
            return (isSubmitter || isInstantSubmitEnabled(policy)) && (shouldShowRterForPaid || !isSettled(iouReport));
        }
    
        if (violationName === CONST.VIOLATIONS.RECEIPT_NOT_SMART_SCANNED) {
            return isPolicyMember && !isSubmitter && !isReportOpen;
        }
    
        return true;
    }

    /**
    * Check if the user should see the violation
    */
    function shouldShowViolation(iouReport: OnyxEntry<Report>, policy: OnyxEntry<Policy>, violationName: ViolationName): boolean {
    const isSubmitter = isCurrentUserSubmitter(iouReport?.reportID);
    const isPolicyMember = isPolicyMemberPolicyUtils(currentUserEmail, policy?.id);
    const isReportOpen = isOpenExpenseReport(iouReport);
    if (violationName === CONST.VIOLATIONS.AUTO_REPORTED_REJECTED_EXPENSE) {
    return isSubmitter;
    }
    if (violationName === CONST.VIOLATIONS.OVER_AUTO_APPROVAL_LIMIT) {
    return isPolicyAdmin(policy) && !isSubmitter;
    }
    if (violationName === CONST.VIOLATIONS.RTER) {
    return isSubmitter || isInstantSubmitEnabled(policy);
    }
    if (violationName === CONST.VIOLATIONS.RECEIPT_NOT_SMART_SCANNED) {
    return isPolicyMember && !isSubmitter && !isReportOpen;
    }
    return true;
    }

    • Then we need to add a new parameter to useTransactionViolations, name it shouldShowRterForSettled, default it to true and pass it as the last param of shouldShowViolation.
    function useTransactionViolations(transactionID?: string, shouldShowRterForPaid = true): TransactionViolations {
        const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {
            canBeMissing: true,
        });
        const [transactionViolations = getEmptyArray<TransactionViolation>()] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, {
            canBeMissing: true,
        });
        const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`, {
            canBeMissing: true,
        });
        const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${iouReport?.policyID}`, {
            canBeMissing: true,
        });
    
        return useMemo(
            () =>
                transactionViolations.filter(
                    (violation: TransactionViolation) => !isViolationDismissed(transaction, violation) && shouldShowViolation(iouReport, policy, violation.name, shouldShowRterForPaid),
                ),
            [transaction, transactionViolations, iouReport, policy, shouldShowRterForPaid],
        );
    }
    
    export default useTransactionViolations;

    function useTransactionViolations(transactionID?: string): TransactionViolations {
    const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {
    canBeMissing: true,
    });
    const [transactionViolations = getEmptyArray<TransactionViolation>()] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, {
    canBeMissing: true,
    });
    const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`, {
    canBeMissing: true,
    });
    const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${iouReport?.policyID}`, {
    canBeMissing: true,
    });
    return useMemo(
    () => transactionViolations.filter((violation: TransactionViolation) => !isViolationDismissed(transaction, violation) && shouldShowViolation(iouReport, policy, violation.name)),
    [transaction, transactionViolations, iouReport, policy],
    );
    }
    export default useTransactionViolations;

    • From TransactionItemRowRBRWithOnyx pass false for the shouldShowRterForPaid param to useTransactionViolations.
      const transactionViolations = useTransactionViolations(transaction?.transactionID);
    • Optional: Instead of filtering the transaction in shouldShowViolation, we can directly filter that when running filter method in useTransactionViolations hook.
      return useMemo(
      () => transactionViolations.filter((violation: TransactionViolation) => !isViolationDismissed(transaction, violation) && shouldShowViolation(iouReport, policy, violation.name)),
      [transaction, transactionViolations, iouReport, policy],
      );

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    • Add some unit test for shouldShowViolation if we decide to update that.

    What alternative solutions did you explore? (Optional)

    • We can directly filter out the rter violations after getting it using useTransactionViolations and pass the filtered violations to getRBRMessages.
      const transactionViolations = useTransactionViolations(transaction?.transactionID);
      const {translate} = useLocalize();
      const theme = useTheme();
      const {sortedAllReportActions: transactionActions} = usePaginatedReportActions(transaction.reportID);
      const transactionThreadId = transactionActions ? getIOUActionForTransactionID(transactionActions, transaction.transactionID)?.childReportID : undefined;
      const {sortedAllReportActions: transactionThreadActions} = usePaginatedReportActions(transactionThreadId);
      const RBRMessages = ViolationsUtils.getRBRMessages(transaction, transactionViolations, translate, missingFieldError, transactionThreadActions);

    Result

  6. sakluger commented on Jul 11, 2025

    @sakluger
    Contributor

    Hey @Pujan92, could you please review the proposal above? Thanks!

  7. nkdengineer commented on Jul 15, 2025

    @nkdengineer
    Contributor

    Proposal

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

    Stop showing RTER violation on the reports page for paid transactions

    What is the root cause of that problem?

    The violation is getting from useTransactionViolations and we don't have the logic to filter out the RTER violation if the transaction is paid

    () => transactionViolations.filter((violation: TransactionViolation) => !isViolationDismissed(transaction, violation) && shouldShowViolation(iouReport, policy, violation.name)),

    function shouldShowViolation(iouReport: OnyxEntry<Report>, policy: OnyxEntry<Policy>, violationName: ViolationName): boolean {
    const isSubmitter = isCurrentUserSubmitter(iouReport?.reportID);
    const isPolicyMember = isPolicyMemberPolicyUtils(currentUserEmail, policy?.id);
    const isReportOpen = isOpenExpenseReport(iouReport);
    if (violationName === CONST.VIOLATIONS.AUTO_REPORTED_REJECTED_EXPENSE) {
    return isSubmitter;
    }
    if (violationName === CONST.VIOLATIONS.OVER_AUTO_APPROVAL_LIMIT) {
    return isPolicyAdmin(policy) && !isSubmitter;
    }
    if (violationName === CONST.VIOLATIONS.RTER) {
    return isSubmitter || isInstantSubmitEnabled(policy);
    }
    if (violationName === CONST.VIOLATIONS.RECEIPT_NOT_SMART_SCANNED) {
    return isPolicyMember && !isSubmitter && !isReportOpen;
    }
    return true;
    }
    /**
    * Check if there is pending rter violation in all transactionViolations with given transactionIDs.
    */
    function allHavePendingRTERViolation(transactions: OnyxEntry<Transaction[] | SearchTransaction[]>, transactionViolations: OnyxCollection<TransactionViolations> | undefined): boolean {
    if (!transactions) {
    return false;
    }

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

    We already have a case for RTER violation in shouldShowViolation function, we only need to add a condition to not show this violation if the report is settled

    if (violationName === CONST.VIOLATIONS.RTER) {
        return (isSubmitter || isInstantSubmitEnabled(policy)) && !isSettled(iouReport);
    }
    

    function shouldShowViolation(iouReport: OnyxEntry<Report>, policy: OnyxEntry<Policy>, violationName: ViolationName): boolean {
    const isSubmitter = isCurrentUserSubmitter(iouReport?.reportID);
    const isPolicyMember = isPolicyMemberPolicyUtils(currentUserEmail, policy?.id);
    const isReportOpen = isOpenExpenseReport(iouReport);
    if (violationName === CONST.VIOLATIONS.AUTO_REPORTED_REJECTED_EXPENSE) {
    return isSubmitter;
    }
    if (violationName === CONST.VIOLATIONS.OVER_AUTO_APPROVAL_LIMIT) {
    return isPolicyAdmin(policy) && !isSubmitter;
    }
    if (violationName === CONST.VIOLATIONS.RTER) {
    return isSubmitter || isInstantSubmitEnabled(policy);
    }
    if (violationName === CONST.VIOLATIONS.RECEIPT_NOT_SMART_SCANNED) {
    return isPolicyMember && !isSubmitter && !isReportOpen;
    }
    return true;
    }
    /**
    * Check if there is pending rter violation in all transactionViolations with given transactionIDs.
    */
    function allHavePendingRTERViolation(transactions: OnyxEntry<Transaction[] | SearchTransaction[]>, transactionViolations: OnyxCollection<TransactionViolations> | undefined): boolean {
    if (!transactions) {
    return false;
    }

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    We can write the unit test for shouldShowViolation and verify that the RTER violation return false if the report is paid.

    What alternative solutions did you explore? (Optional)

    NA

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  8. Krishna2323 commented on Jul 15, 2025

    @Krishna2323
    Contributor

    PROPOSAL UPDATED

    • Updated the proposal because useTransactionViolations is change recently. The solution is still almost the same.
  9. melvin-bot commented on Jul 15, 2025

    @melvin-bot

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

  10. Pujan92 commented on Jul 15, 2025

    @Pujan92
    Contributor

    I am reviewing it Melvin..

  11. 22 remaining items

  12. melvin-bot commented on Jul 25, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.85-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-08-01. 🎊

    For reference, here are some details about the assignees on this issue:

    • @Pujan92 requires payment through NewDot Manual Requests
    • @Krishna2323 requires payment (Needs manual offer from BZ)
  13. melvin-bot commented on Jul 25, 2025

    @melvin-bot

    @Pujan92 @sakluger The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  14. Pujan92 commented on Jul 31, 2025

    @Pujan92
    Contributor

    We don't need a checklist here as it is a new change.

  15. sakluger commented on Aug 1, 2025

    @sakluger
    Contributor

    Payment Summary

    Contributor: @Krishna2323 $250 via NewDot
    Contributor+: @Pujan92 $250 via Newdot

  16. melvin-bot commented on Aug 1, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@sakluger)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  17. Krishna2323 commented on Aug 2, 2025

    @Krishna2323
    Contributor

    @sakluger I'm now eligible for NewDot payments, so I've declined the Upwork contract. Apologies for not mentioning it earlier.

  18. sakluger commented on Aug 2, 2025

    @sakluger
    Contributor

    Hi @Krishna2323, it looks like you became eligible for NewDot payments on July 22, but since you were assigned to this issue on July 16, before eligibility kicked in, we’ll still need to process payment through Upwork for this one.

    Here's the new offer: https://www.upwork.com/nx/wm/offer/108273149

  19. Krishna2323 commented on Aug 2, 2025

    @Krishna2323
    Contributor

    @sakluger could you please check this comment? If there is still any issue, I'm happy to proceed with Upwork. I have not declined the offer this time 😅. Thanks!

    I looked into this, and @Krishna2323, your eligibility date for NewDot payments is 2025-02-15. So while you might have only been set up recently, that's the date to consider when deciding to cancel an Upwork contract to be paid in NewDot instead.

    This issue, and the two other issues you referenced above, were all contracted after the eligibility date. We can proceed with ND payments for these. 👍

  20. sakluger commented on Aug 4, 2025

    @sakluger
    Contributor

    Thanks for pointing me to that comment, you're correct! Our internal documentation listed the wrong eligibility date, so I've updated our documentation.

    I withdrew the Upwork contract and updated the payment summary above so you can request payment via NewDot.

  21. Krishna2323 commented on Aug 4, 2025

    @Krishna2323
    Contributor

    Requested in NewDot.

  22. isabelastisser commented on Aug 5, 2025

    @isabelastisser
    Contributor

    @Pujan92 has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Vendor found in VML: True. Status: Active

    Amount requested: $250.00. Matches the payment summary here.

    I am not already the BZ assignee, so I have approved this payment.

  23. flaviadefaria commented on Aug 13, 2025

    @flaviadefaria
    Contributor

    $250 approved for @Krishna2323

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions