Skip to content
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: List still shows receipt when removed #44762

Merged
merged 11 commits into from
Jul 30, 2024
10 changes: 9 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7215,7 +7215,15 @@ function payInvoice(paymentMethodType: PaymentMethodType, chatReport: OnyxTypes.

function detachReceipt(transactionID: string) {
const transaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
const newTransaction = transaction ? {...transaction, filename: '', receipt: {}} : null;
const newTransaction = transaction
? {
...transaction,
filename: '',
receipt: {
source: '',
},
}
: null;

const optimisticData: OnyxUpdate[] = [
{
Expand Down
11 changes: 9 additions & 2 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,22 @@ function ReportScreen({

// If a user has chosen to leave a thread, and then returns to it (e.g. with the back button), we need to call `openReport` again in order to allow the user to rejoin and to receive real-time updates
useEffect(() => {
if (!shouldUseNarrowLayout || !isFocused || prevIsFocused || !ReportUtils.isChatThread(report) || report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) {
if (
!shouldUseNarrowLayout ||
!isFocused ||
prevIsFocused ||
!ReportUtils.isChatThread(report) ||
report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN ||
isSingleTransactionView
) {
return;
}
Report.openReport(report.reportID);

// We don't want to run this useEffect every time `report` is changed
// Excluding shouldUseNarrowLayout from the dependency list to prevent re-triggering on screen resize events.
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [prevIsFocused, report.notificationPreference, isFocused]);
}, [prevIsFocused, report.notificationPreference, isFocused, isSingleTransactionView]);

useEffect(() => {
// We don't want this effect to run on the first render.
Expand Down
Loading