Repository navigation
Fix distance preview mismatch with expense details header #101068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nabi-ebrahimi
wants to merge
49
commits into
Expensify:main
Choose a base branch
from
nabi-ebrahimi:fix-distance-preview-header-mismatch-100188
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,507
−61
Open
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
526afbe
Fix distance preview mismatch with expense details header
nabi-ebrahimi b585e18
Sync distance preview accessibility amount with visible display
nabi-ebrahimi fbf832d
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 205e28a
Deduplicate distance preview normalization and add regression tests
nabi-ebrahimi ea71170
Extract shared distance display transaction hook
nabi-ebrahimi bd2f262
Fix display transaction hook imports and report context handling
nabi-ebrahimi 33ca266
Align distance preview policy context and add regression coverage
nabi-ebrahimi f1afddd
Align distance preview policy detection and strengthen regression tests
nabi-ebrahimi db787f9
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi ae9a578
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 66d10f4
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 2e3ea23
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 69dbb37
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 083ddb2
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 89ff570
Preserve historical rates and manual amounts in self-DM distance disp…
nabi-ebrahimi 898418a
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 19b6623
Fix nested ternary lint error in distance transaction display
nabi-ebrahimi cae6c9b
Revert historical rate and manual amount handling for distance displays
nabi-ebrahimi 0863c35
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 47a7be4
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi e638712
Fix distance expense previews to preserve saved rates
nabi-ebrahimi 1754bc3
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 599a060
Add coverage for matching currency symbols in distance previews
nabi-ebrahimi 431e5a2
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 85a23da
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 529645f
Clarify distance rate restoration logic
nabi-ebrahimi 2b82f09
Ensure saved distance restoration flag is boolean
nabi-ebrahimi 9da497e
Restore all-betas permission check
nabi-ebrahimi b51f015
Fix optimistic Self DM distance rate calculation
nabi-ebrahimi 1e80e8d
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 44204ea
`Preserve full distance amount across offline rate changes`
nabi-ebrahimi 5e75ad4
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi d4a4113
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 999ceec
Fix distance expense amount changing when switching languages
nabi-ebrahimi 0706971
Preserve saved distance rates when currency data loads
nabi-ebrahimi ec0c250
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi a8f39bd
Extract distance merchant parsing and add formatter round-trip tests
nabi-ebrahimi 6d1a5d5
Document policy parameters in useDisplayTransaction
nabi-ebrahimi 06d7c5c
Add explicit return type to useDisplayTransaction
nabi-ebrahimi 55aac36
Use a named function for restoreSavedReducedValues
nabi-ebrahimi 2612b53
Share distance merchant prefix formatting
nabi-ebrahimi 597b8d5
Cover cross-policy rate lookup and Self DM route edits
nabi-ebrahimi e294528
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi c923cda
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi 7ec6bd9
Preserve historical distance amounts after workspace rate changes
nabi-ebrahimi 7dc7c34
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi d1dc6de
Fix commuter-excluded amounts when moving distance expenses back to r…
nabi-ebrahimi 7113e34
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi af40e39
Merge branch 'main' into fix-distance-preview-header-mismatch-100188
nabi-ebrahimi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import {getDistanceRateCustomUnitRate} from '@libs/PolicyUtils'; | ||
| import {getDisplayTransactionWithoutInvalidCommuterExclusion, isDistanceRequest} from '@libs/TransactionUtils'; | ||
|
|
||
| import type {Policy, Transaction} from '@src/types/onyx'; | ||
|
|
||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
|
|
||
| import {useCurrencyListActions} from './useCurrencyList'; | ||
| import useDistanceRateOriginalPolicy from './useDistanceRateOriginalPolicy'; | ||
| import useLocalize from './useLocalize'; | ||
|
|
||
| type UseDisplayTransactionResult = { | ||
| displayTransaction: OnyxEntry<Transaction>; | ||
| distanceOriginalPolicy: OnyxEntry<Policy>; | ||
| }; | ||
|
|
||
| /** | ||
| * Normalizes a transaction for display, keeping commuter-reduced values in policy | ||
| * expense chats and restoring full-route values elsewhere when possible. | ||
| * | ||
| * @param policy Fallback policy used for display normalization when no original policy is found. | ||
| * @param rateLookupPolicy Policy checked for the selected rate before searching other policies. Defaults to policy. | ||
| */ | ||
| function useDisplayTransaction( | ||
| transaction: OnyxEntry<Transaction>, | ||
| isPolicyExpenseChat: boolean, | ||
| policy?: OnyxEntry<Policy>, | ||
| rateLookupPolicy: OnyxEntry<Policy> = policy, | ||
| ): UseDisplayTransactionResult { | ||
| const {translate} = useLocalize(); | ||
| const {getCurrencySymbol} = useCurrencyListActions(); | ||
| const customUnitRateID = isDistanceRequest(transaction) ? transaction?.comment?.customUnit?.customUnitRateID : undefined; | ||
| const shouldLookupDistancePolicy = !!customUnitRateID && !getDistanceRateCustomUnitRate(rateLookupPolicy, customUnitRateID); | ||
| const distanceOriginalPolicy = useDistanceRateOriginalPolicy(customUnitRateID, shouldLookupDistancePolicy); | ||
|
nabi-ebrahimi marked this conversation as resolved.
|
||
| const displayTransaction = getDisplayTransactionWithoutInvalidCommuterExclusion({ | ||
| transaction, | ||
| isPolicyExpenseChat, | ||
| policy: distanceOriginalPolicy ?? policy, | ||
| translate, | ||
| getCurrencySymbol, | ||
| }); | ||
|
|
||
| return {displayTransaction, distanceOriginalPolicy}; | ||
| } | ||
|
|
||
| export default useDisplayTransaction; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.