From 1708b0f8be7c219ecd8c1c88fa976e1a7f1add10 Mon Sep 17 00:00:00 2001 From: Joshua Rogers Date: Tue, 3 Feb 2026 20:15:42 +0800 Subject: [PATCH] avoid double-settling Promise in checkWalletAvailability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TapAndPay environment Task invokes onComplete for both success and failure; our handler always resolve()d there, then also reject()d in addOnFailureListener. On failures this meant the same React Native Promise could be settled twice (resolve then reject), causing “Promise already settled” warnings and flaky JS-side behavior. Handle the result in a single callback and resolve once with task.isSuccessful. (cherry picked from commit 6acaa43e50bc63f4ae48746849b36d2f00fe6d48) --- .../src/main/java/com/expensify/wallet/WalletModule.kt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/android/src/main/java/com/expensify/wallet/WalletModule.kt b/android/src/main/java/com/expensify/wallet/WalletModule.kt index 368f31f..30bd6c3 100644 --- a/android/src/main/java/com/expensify/wallet/WalletModule.kt +++ b/android/src/main/java/com/expensify/wallet/WalletModule.kt @@ -107,14 +107,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) : @ReactMethod override fun checkWalletAvailability(promise: Promise) { tapAndPayClient.environment.addOnCompleteListener { task -> - if (task.isSuccessful) { - promise.resolve(true) - } else { - promise.resolve(false) - } - }.addOnFailureListener { e -> - promise.reject(E_OPERATION_FAILED, "Checking Wallet availability failed: ${e.localizedMessage}") - } + promise.resolve(task.isSuccessful) } @ReactMethod