Currently we have is{Type}Request utils for every request type here which:
- Check for
iouRequestType during the expense creation flow before the transaction has been saved to the server
- When the transaction object is returned from the server after it has been created, checks for different transaction fields specific to the checked request type, since
iouRequestType was not being returned from the server for transactions.
The second case has started to be a problem because we were not able to easily distinguish a map request from a GPS request, as their server transaction objects have no differences, and we were forced to use a temporary hack to make the utils work properly for these request types.
This has changed with this backend change where we started sending iouRequestType from the server for all transactions. Because of that, we can simplify the is{Type}Request() utils to only check for iouRequestType in both cases.
Example:
function isPerDiemRequest(transaction: OnyxEntry<Transaction>): boolean {
// This is used during the expense creation flow before the transaction has been saved to the server
if (transaction && Object.hasOwn(transaction, 'iouRequestType')) {
return transaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.PER_DIEM;
}
// This is the case for transaction objects once they have been saved to the server
const type = transaction?.comment?.type;
const customUnitName = transaction?.comment?.customUnit?.name;
return type === CONST.TRANSACTION.TYPE.CUSTOM_UNIT && customUnitName === CONST.CUSTOM_UNITS.NAME_PER_DIEM_INTERNATIONAL;
}
Can be simplified to this:
function isPerDiemRequest(transaction: OnyxEntry<Transaction>): boolean {
if (!transaction || !Object.hasOwn(transaction, 'iouRequestType')) {
return false;
}
return transaction.iouRequestType === CONST.IOU.REQUEST_TYPE.PER_DIEM;
}
Issue Owner
Current Issue Owner: @mananjadhav
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022040116440968488926
- Upwork Job ID: 2040116440968488926
- Last Price Increase: 2026-04-10
Currently we have
is{Type}Requestutils for every request type here which:iouRequestTypeduring the expense creation flow before the transaction has been saved to the serveriouRequestTypewas not being returned from the server for transactions.The second case has started to be a problem because we were not able to easily distinguish a map request from a GPS request, as their server transaction objects have no differences, and we were forced to use a temporary hack to make the utils work properly for these request types.
This has changed with this backend change where we started sending iouRequestType from the server for all transactions. Because of that, we can simplify the is{Type}Request() utils to only check for iouRequestType in both cases.
Example:
Can be simplified to this:
Issue Owner
Current Issue Owner: @mananjadhavUpwork Automation - Do Not Edit