App: [HOLD for payment 2024-02-20] Implement Client-side Violations when updating money requests

  • Design Doc
  • The following should only apply to users in the violations beta
  • Let’s connect EditRequestPage to the POLICY, and TRANSACTION_VIOLATIONS Onyx collections so we can get
    • requiresTag, requiresCategory, hasMultipleTagLists, and isTaxTrackingEnabled from the policy, and
    • The transaction violations from Onyx
  • In src/pages/EditRequestPage.js let’s pass policyID to editMoneyRequest, and in there pass it to IOU.updateDistanceRequest and IOU.editMoneyRequest
  • Let’s update src/libs/actions/IOU.js
    • In editMoneyRequest above where we set optimisticData, call ViolationUtils.getViolationsOnyxData(transactionChanges, transactionViolations, policyRequiresTags, policyTags, policyRequiresCategories, policyCategories), and add the return value to the optimisticData
    • Similarly in updateDistanceRequest after the last call to optimisticData.push, we call ViolationUtils.getViolationsOnyxData(transactionChanges, transactionViolations, policyRequiresTags, policyTags, policyRequiresCategories, policyCategories) and push the return value to optimisticData
  • We can set the value of failure data to an object like in the snippet below, where transactionViolations has the data from Onyx
  • Once the request is submitted, violations will be calculated on the server in EditMoneyRequest API command and pushed down to the client, but nothing about the violations that are calculated on the client should change
{
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`,
    value: transactionViolations,
}

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 22 (13 by maintainers)

Most upvoted comments

In final review / testing