Skip to content

[$250] [GPS]Transactions - Always use iouRequestType to check for request type #83028

@GCyganek

Description

@GCyganek

Currently we have is{Type}Request utils for every request type here which:

  1. Check for iouRequestType during the expense creation flow before the transaction has been saved to the server
  2. 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 OwnerCurrent 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

Metadata

Metadata

Labels

DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsImprovementItem broken or needs improvement.Overdue

Type

No type
No fields configured for issues without a type.

Projects

Status

HIGH

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions