-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: show error message for invalid receipt #34087
Changes from 2 commits
5c8b972
290c569
d78b26e
2a20b9b
670bd8b
f48ddc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import Str from 'expensify-common/lib/str'; | ||
import _ from 'lodash'; | ||
import type {ImageSourcePropType} from 'react-native'; | ||
import ReceiptDoc from '@assets/images/receipt-doc.png'; | ||
import ReceiptGeneric from '@assets/images/receipt-generic.png'; | ||
|
@@ -7,6 +8,7 @@ import ReceiptSVG from '@assets/images/receipt-svg.png'; | |
import CONST from '@src/CONST'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type {Transaction} from '@src/types/onyx'; | ||
import type {ReceiptError} from '@src/types/onyx/Transaction'; | ||
import * as FileUtils from './fileDownload/FileUtils'; | ||
|
||
type ThumbnailAndImageURI = { | ||
|
@@ -30,9 +32,10 @@ type FileNameAndExtension = { | |
*/ | ||
function getThumbnailAndImageURIs(transaction: Transaction, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI { | ||
// URI to image, i.e. blob:new.expensify.com/9ef3a018-4067-47c6-b29f-5f1bd35f213d or expensify.com/receipts/w_e616108497ef940b7210ec6beb5a462d01a878f4.jpg | ||
const path = transaction?.receipt?.source ?? receiptPath ?? ''; | ||
const errors = _.findLast(transaction.errors) as ReceiptError | null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need union type here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error can be undefined (receipt without error), so I think it should be ReceiptError | undefined |
||
const path = errors?.source ?? transaction?.receipt?.source ?? receiptPath ?? ''; | ||
tienifr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// filename of uploaded image or last part of remote URI | ||
const filename = transaction?.filename ?? receiptFileName ?? ''; | ||
const filename = errors?.filename ?? transaction?.filename ?? receiptFileName ?? ''; | ||
const isReceiptImage = Str.isImage(filename); | ||
|
||
const hasEReceipt = transaction?.hasEReceipt; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We missed handling the case of
createChat
errorfields which would happen when the creation of the chat itself fails thereby causing #43481.