Repository navigation
Fix offline self-DM distance rate resolution - #96903
roryabraham merged 12 commits into
Conversation
|
@Krishna2323 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
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.
|
JmillsExpensify
left a comment
There was a problem hiding this comment.
Did not test an adhoc, though the testing steps LGTM
|
@Krishna2323, Gentle bump. thanks. |
|
Will be reviewing this today. |
|
@Krishna2323, Addressed your feedback. Could you take another look? Thanks! |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@Krishna2323, Thanks. I've addressed your feedback. |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid_hybrid.mp4Android: mWeb Chromeandroid_mWeb.mp4iOS: HybridAppios_hybrid.mp4iOS: mWeb Safariios_mWeb.mp4MacOS: Chrome / Safariweb_chrome.mp4 |
|
@MelvinBot review |
Review — looks solid ✅I re-reviewed the diff against the surrounding code and Onyx merge semantics. All three of your earlier inline comments are correctly addressed, all checks pass, and I found no functional bugs. Two small notes below. Prior feedback — all resolved:
Correctness confirmed:
Two things worth a glance:
Nothing blocking here — nice, tightly-scoped fix. |
|
@nabi-ebrahimi, could you please check the comments above? Otherwise, it looks good. |
@Krishna2323, I tested that case as well by creating a distance expense directly in the workspace chat, both offline and online, and it worked correctly in both cases. |
|
@roryabraham, could you please take a look at this when you get a chance. thanks. |
| const workspaceDistanceCustomUnit = getDistanceRateCustomUnit(policy); | ||
| const workspaceDistanceUnit = workspaceDistanceCustomUnit?.attributes?.unit; | ||
| optimisticTransaction.comment = { | ||
| ...optimisticTransaction.comment, |
There was a problem hiding this comment.
Why do we need to do a shallow copy here?
If we're modifying optimisticTransaction.comment in-place, could we just as easily modify only the nested properties we want to change?
It's more verbose, but seems slightly more performant, and also imo more readable than this many-spread operation we have here.
diff --git a/src/libs/actions/IOU/MoneyRequestBuilder.ts b/src/libs/actions/IOU/MoneyRequestBuilder.ts
index ac95dbe6bb3..9c9837117a0 100644
--- a/src/libs/actions/IOU/MoneyRequestBuilder.ts
+++ b/src/libs/actions/IOU/MoneyRequestBuilder.ts
@@ -1542,18 +1542,26 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma
if (action === CONST.IOU.ACTION.SUBMIT && isDistanceRequest) {
const workspaceDistanceCustomUnit = getDistanceRateCustomUnit(policy);
const workspaceDistanceUnit = workspaceDistanceCustomUnit?.attributes?.unit;
- optimisticTransaction.comment = {
- ...optimisticTransaction.comment,
- customUnit: {
- ...optimisticTransaction.comment?.customUnit,
- ...(workspaceDistanceCustomUnit?.customUnitID && {customUnitID: workspaceDistanceCustomUnit.customUnitID}),
- ...(customUnitRateID && {customUnitRateID}),
- ...(workspaceDistanceUnit && {distanceUnit: workspaceDistanceUnit}),
- ...(distance !== undefined && {quantity: distance}),
- ...(!!workspaceDistanceCustomUnit && {defaultP2PRate: null}),
- name: optimisticTransaction.comment?.customUnit?.name ?? existingTransaction?.comment?.customUnit?.name ?? CONST.CUSTOM_UNITS.NAME_DISTANCE,
- },
- };
+
+ optimisticTransaction.comment ??= {};
+ optimisticTransaction.comment.customUnit ??= {};
+
+ optimisticTransaction.comment.customUnit.name = optimisticTransaction.comment.customUnit.name ?? existingTransaction?.comment?.customUnit?.name ?? CONST.CUSTOM_UNITS.NAME_DISTANCE;
+ if (workspaceDistanceCustomUnit?.customUnitID) {
+ optimisticTransaction.comment.customUnit.customUnitID = workspaceDistanceCustomUnit.customUnitID;
+ }
+ if (customUnitRateID) {
+ optimisticTransaction.comment.customUnit.customUnitRateID = customUnitRateID;
+ }
+ if (workspaceDistanceUnit) {
+ optimisticTransaction.comment.customUnit.distanceUnit = workspaceDistanceUnit;
+ }
+ if (distance !== undefined) {
+ optimisticTransaction.comment.customUnit.quantity = distance;
+ }
+ if (workspaceDistanceCustomUnit) {
+ optimisticTransaction.comment.customUnit.defaultP2PRate = null;
+ }
}
if (isSplitExpense && existingTransaction) {
|
@roryabraham, addressed your feedback, thanks |
|
🚧 roryabraham has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.4.51-0 🚀
|
No help site changes requiredThis PR is a bug fix that restores already-intended behavior — it does not add a feature, rename anything, or change any documented user-facing flow. What it does: Fixes the offline optimistic data so that a tracked distance expense submitted from a self DM to a workspace keeps its destination workspace policy/rate/unit data while offline. Per the linked issue Expensify/App#93575, the Rate field was rendering blank offline; this makes it correctly show the selected rate and workspace distance unit. Changes are confined to two frontend files ( Why no docs update: I reviewed the relevant help articles — Set-distance-rates.md, Distance-Expenses.md, and Track-Personal-Expenses.md. None of them document the offline optimistic-data behavior of the Rate field, the self-DM "Submit it to someone" flow's rate persistence, or any of the specifics this PR touches. The user-facing feature (distance rates, submitting from a self DM) is unchanged in what it's supposed to do — this only fixes an offline defect. There's nothing in Since no changes are needed, I did not create a draft help site PR. @nabi-ebrahimi, if you believe any help article should describe this behavior (e.g., offline expectations for distance rates), let me know and I'll draft the PR. |
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.51-1 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
Fixes the offline optimistic data for submitting a tracked distance expense from self DM to a workspace.
The change ensures the moved distance expense keeps the destination workspace policy/rate data offline by:
policyIDandchatReportIDon the optimistic transaction-thread reportcustomUnitRateIDthrough the optimistic money request buildercustomUnitdata after merging the old tracked transactionThis keeps the Rate picker populated, keeps the selected rate selected, and keeps the workspace distance unit visible while offline.
Fixed Issues
$ #93575
PROPOSAL: #93575 (comment)
Tests
Offline tests
Same as tests.
QA Steps
Same as tests.
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### 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
Android: Native
Screen_Recording_20260724_202831_New.Expensify.Dev.mp4
Android: mWeb Chrome
Screen_Recording_20260724_211721_Chrome.mp4
iOS: Native
Screen.Recording.2026-07-24.at.9.45.37.PM.mp4
iOS: mWeb Safari
Screen.Recording.2026-07-24.at.9.49.14.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-07-24.at.5.49.54.PM.mp4