Skip to content

Clean up SettlementButton #79387

@roryabraham

Description

@roryabraham

Coming from #78915...

Problem

The SettlementButton component is quite complex (and important!), and I struggled to review changes made to part of it due to its complexity.

Solution

Let's clean up this important component! In order:

  1. Add automated UI tests covering the business logic for this component. customText and secondLineText alone have many permutations of conditions and expected results. These can be captured and documented by automated tests, which will help developers understand this component and more confidently make changes.
  2. Remove manual memoization to make it compile with React Compiler. There are 25 instances of this warning:
This component hasn't been memoized by React Compiler.
Reason: Existing memoization could not be preserved

This manual memoization is making the component more complex and longer.

  1. (exploration needed) Break it down into smaller, distinct components (by report type?) (i.e: using composition). It looks like there's significant differences in behavior for invoices vs expense reports vs IOU reports. Rather than having all three wrapped up in one component, let's DRY the common parts into a shared hook and keep the other parts separate, using the correct component for each type.

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions