Repository navigation
refactor: remove unsafe assertions from route params, phone, report field, image and composer utilities - #103222
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
Seatbelt-Operation: 38ab9f52-d568-4be9-a6ab-b762a2577d6d
c0b2f62 to
fb68edc
Compare
Seatbelt-Operation: main-20261030-103222-sign-915852cb-a7f0-40fd-81e2-126b6882dbec
Move the parser unchanged into FormulaParser.ts so report field utils can import it without an import cycle. Keep the parser's phone number input. Remove the new tests.
…input Formula.ts no longer re-exports FormulaPart and FORMULA_PART_TYPES, which nothing imports from it. PhoneNumber passes the raw input, because the parser always returns it unchanged.
|
@situchan, could you please review this PR? Merged |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb Safari |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 blimpich has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/blimpich in version: 9.5.53-0 🚀
|
|
No help site update needed — this PR refactors internal utilities without adding user-facing features, changing documented workflows or labels, or removing beta gates. |
|
🚀 Deployed to production by https://github.com/arosiclair in version: 9.5.53-3 🚀
Bundle Size Analysis (Sentry): |
1 similar comment
|
🚀 Deployed to production by https://github.com/arosiclair in version: 9.5.53-3 🚀
Bundle Size Analysis (Sentry): |

Explanation of Change
Remove unsafe type assertions (
ascasts) from five utility files.getParamsFromRoute: the screen name is a plain string, so the route config and shared params maps are read as string-keyed maps that can miss the name, instead of casting the name toScreen.PhoneNumber: the two invalid results are returned as plain objects that matchParsedPhoneNumberInvalid.number.inputis set to the raw input string, which is what the parser already puts there.WorkspaceReportFieldUtils: the formula parser (parse,extract,parsePart,FORMULA_PART_TYPES,FormulaPart) moved unchanged fromFormula.tsto a newFormulaParser.ts. Report field utils now import it normally instead of a typedrequirethat avoided an import cycle.Formula.tsimports the parser and still exportsparse. It no longer exportsFORMULA_PART_TYPESandFormulaPart, because nothing imports them from there.getImageResolution: theonloadhandler reads the size from theimagevariable instead of castingthis.setTextInputSelection: checks which selection method the input has (DOMsetSelectionRangeon web,setSelectionon native) instead of casting to each type.No behavior change.
Changed files
src/libs/Formula.tssrc/libs/FormulaParser.tssrc/libs/Navigation/helpers/getParamsFromRoute.tssrc/libs/PhoneNumber.tssrc/libs/WorkspaceReportFieldUtils.tssrc/libs/fileDownload/getImageResolution.tssrc/libs/focusComposerWithDelay/setTextInputSelection.tsFixed Issues
$ #94739
PROPOSAL: #94739 (comment)
Tests
C01 Workspace navigation and report field formulas
Precondition: Signed in as a workspace admin. The workspace is on the Control plan and has report fields turned on.
{report:total}as the initial value.{report:unknown}.C02 Avatar image bounds
Precondition: Signed in as a workspace admin. Have a 640x480 PNG and a 79x79 PNG on the device. The changed code runs on web and mWeb; on Android and iOS this checks the same result.
C03 Cursor after emoji insertion
Precondition: Signed in, with any chat open. Run this case at least on Android native and Android Chrome, where the changed cursor code runs.
alpha beta, then choose Edit comment on it (on web on a computer, hover the message and press the pencil icon; on Android and iOS, long-press the message).C04 Phone invitation validation
Precondition: Signed in as a workspace admin.
+115005550009.+15005550006.No new tests are added, because behavior does not change. The existing
FormulaTest,WorkspaceReportFieldUtilsTest,PhoneNumberTestandhasDifferentSplitScopesuites cover the formula, phone and route code. The image size and cursor changes are covered by C02 and C03.Offline tests
N/A. The changed code is local parsing, lookup and cursor logic, so offline behavior does not change.
QA Steps
Same as tests.
PR Author Checklist
The new-copy, CSS, asset, and layout-design conditions are inapplicable because this diff changes no copy, styles, or assets. Desktop Chrome execution, recording and bounded console checks are recorded below. Other platform execution, high-traffic testing and offline testing remain unperformed. The focused tests cover only the paths described above.
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Screenshots/Videos (7)
C01 desktop
PR-103222-C01-D.mp4
C01 phone-sized
PR-103222-C01-M.mp4
C02 desktop
PR-103222-C02-D.mp4
C02 phone-sized
PR-103222-C02-M.mp4
C03 desktop
PR-103222-C03-D.mp4
C03 phone-sized
PR-103222-C03-M.mp4
C04 desktop
103222-C04-desktop.mp4