Closed lindboe closed 8 months ago
Triggered auto assignment to @CortneyOfstad (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details.
Platforms
in OP are β
)I'm not super familiar with JS console errors, so going to get engineering eyes on it so see if it works under a Wave π
Triggered auto assignment to @tylerkaraszewski (Engineering
), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
Not overdue
Relevant discussion: https://expensify.slack.com/archives/C01GTK53T8Q/p1699453425518949?thread_ts=1699358032.439529&cid=C01GTK53T8Q Not priority but this is something to be fixed for sure
I can take this as C+
@tylerkaraszewski, @CortneyOfstad Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@tylerkaraszewski, @CortneyOfstad Eep! 4 days overdue now. Issues have feelings too...
Giving @situchan the C+ role here.
@tylerkaraszewski, @CortneyOfstad, @situchan Whoops! This issue is 2 days overdue. Let's get this updated quick!
@tylerkaraszewski, @CortneyOfstad, @situchan Whoops! This issue is 2 days overdue. Let's get this updated quick!
@tylerkaraszewski @CortneyOfstad @situchan this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
Not overdue β was OoO for the holidays π
@tylerkaraszewski, @CortneyOfstad, @situchan Eep! 4 days overdue now. Issues have feelings too...
Job added to Upwork: https://www.upwork.com/jobs/~0167764be02a30eae1
Current assignee @situchan is eligible for the External assigner, not assigning anyone new.
Just realized those labels were not applied, so added them now
After creating a payment request, a prop-types warning mysteriously pops up in the console, the warning disappears later on.
So here's my observations:
Here's a sane explanation as to why this warning shows up:
So, after react renders the list of transactions, it realizes that for one transaction, the receipt field is an array, hence the warning.
When we reload the page for the first time after creating the transaction, we use the cached list of transactions (so we can render things faster), while also updating the cache in the background with potentially new information - thing is: the OpenReport RPC (the one that's made in the background and updates the cache) lists all transactions with the correct receipt field (an object, not an array), so after this is done, all the transactions in our cache are correct (meaning all of them have an object, not an array in the receipt field), thus, the warning disappears for subsequent renders.
No 1: Won't require a change in the frontend code at all. No 2: Is just meant to be used as a temporary solution as it makes the frontend code a bit harder to understand for no good reason.
Edit: Just using the proper template for a proposal
π£ @hanar3! π£ Hey, it seems we donβt have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Contributor details Your Expensify account email: vitorhms10@gmail.com Upwork Profile Link: https://www.upwork.com/freelancers/~0110244da8f5486b43
β Contributor details stored successfully. Thank you for contributing to Expensify!
@tylerkaraszewski @CortneyOfstad @situchan this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!
Not overdue
@situchan any ideas on the proposals above? Thanks!
π£ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? πΈ
@hanar3 can you please update proposal based on our codebase? Seems like you proposed after testing only.
@hanar3 can you please update proposal based on our codebase? Seems like you proposed after testing only.
@situchan Sure can make an updated proposal, but can you clarify what exactly you want to see updated?
My proposal was not after testing only - I was actively looking at the codebase. I left out most of the technicalities to keep the proposal simple enough, but I'll be happy to point you to the exact lines of code where the data flows through before it gets to the warning, if that's what you expect.
I'll be happy to point you to the exact lines of code where the data flows through before it gets to the warning, if that's what you expect.
yes please
@situchan hi again! hopefully this helps clarify things (let me know if it doesn't make sense!)
src/pages/iou/request/step/IOURequestStepConfirmation.js
line 354 the function createTransaction
gets called when the Request button is pressedcreateTransaction
function falls in the basecase (line 277), where it calls the requestMoney
function.requestMoney
callsIOU.requestMoney
, this is what issues the API call (POST to https://dev.new.expensify.com:8082/api?command=RequestMoney) as well as a write to react-native-onyx (the cache). The response of this API call is where the actual problem is!
4.The cache-write happens in the functionSaveResponseToOnyx
which is defined in libs/Middleware/SaveResponseToOnyx.ts
.If we put a log to on SaveResponseToOnyx around here:
// ... SaveResponseToOnyx.ts
const responseToApply = {
type: CONST.ONYX_UPDATE_TYPES.HTTPS,
lastUpdateID: Number(response?.lastUpdateID ?? 0),
previousUpdateID: Number(response?.previousUpdateID ?? 0),
request,
response: response ?? {},
};
console.log(responseToApply);
And then make a manual request in the webapp, we can see exactly what's being stored in the cache after an API call - this contains the backend response unchanged, so it's almost the same as just looking at the network tab. (Omitted some things for brevity)
// Result of RequestMoney call below
{
"transaction": {
"amount": 100,
"billable": false,
"cardID": 0,
"category": "",
"comment": {
"comment": ""
},
"created": "2024-01-15",
"currency": "BRL",
"externalID": "",
"filename": "",
"mcc": "",
"merchant": "(none)",
"modifiedAmount": 0,
"modifiedCreated": "",
"modifiedCurrency": "",
"modifiedMCC": "",
"modifiedMerchant": "",
"originalAmount": 0,
"originalCurrency": "",
"parentTransactionID": "",
"receipt": [], // -----> The problem is here!
"reimbursable": true,
"reportID": "4411715524491711",
"status": "Posted",
"tag": "",
"transactionID": "6427571048478146643"
},
"transactionID": "6427571048478146643",
}
}
This transaction is then merged with the rest of the transactions that are already there. Hopefully you can see the problem now: After the RequestMoney
call specifically, the result transaction comes with an empty array in the receipt field (should be an object, that's what we're expecting). That's why I am saying this issue should be ideally be fixed in the backend, not in the frontend. When the "cache merge" happens, is when react is instructed to re-render the list of transactions, which causes prop-types to see a malformed entry in there resulting in the warning.
For reference, the rest of the transactions that are already on the cache come from the OpenReport
API call, this returns a list of transactions that looks like this:
// Command=OpenReport
{
"transactions_1426066331425242734": {
"amount": 100,
"billable": false,
"cardID": 0,
"category": "",
"comment": {
"comment": ""
},
"created": "2024-01-08",
"currency": "BRL",
"filename": "",
"merchant": "(none)",
"modifiedAmount": 0,
"modifiedCreated": "",
"modifiedCurrency": "",
"modifiedMerchant": "",
"originalAmount": 0,
"originalCurrency": "",
"parentTransactionID": "",
"receipt": {}, // ---> Receipt is an object here, not an array
"reimbursable": true,
"reportID": "4411715524491711",
"status": "Posted",
"tag": "",
"transactionID": "1426066331425242734",
"hasEReceipt": false
}
}
Since the cache is updated on OpenReport
and an API call to that is made when the app first opens, the issue will be auto-fixed after one or two page reloads, because the malformed entry returned from RequestMoney
is overridden with a proper transaction entry.
@tylerkaraszewski @CortneyOfstad @situchan this issue is now 4 weeks old and preventing us from maintaining WAQ, can you:
Thanks!
Current assignee @situchan is eligible for the Internal assigner, not assigning anyone new.
Not overdue π
@situchan any follow-up on the comment here?
@situchan any update?
As originally discussed in slack, we should fix this in backend. As all are focused on waves, not prioritized at the moment and bug existed for long time.
Not overdue. Can we move this to Weekly?
Not overdue π
@tylerkaraszewski @situchan β do we think it would be better to adjust this to Monthly instead of Weekly?
@lindboe I attempted to recreate this in my test account and could not get anything to populate in the JS console, as shown below:
If the issue pops up again, can you reopen the GH @lindboe? Thank you!
This is dev console error, not happening on production app
Oh, thanks for the clarification @situchan! Reopening now π
Reached out to VIP-Split here
Current assignee @situchan is eligible for the External assigner, not assigning anyone new.
Current assignee @situchan is eligible for the Internal assigner, not assigning anyone new.
Sorry β I was trying to adjust it back to weekly and the tags got all wonky. In regards to this being corrected on the backend, @tylerkaraszewski do you have any updates as to when this may get worked on? Thanks!
I am heading OoO (back March 11th) so reassigning BZ to have someone keep an eye on this until I am back. Thanks!
Triggered auto assignment to @kadiealexander (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details.
{}
to []
I'm back from OoO β thanks @kadiealexander for keeping an eye on things!
If you havenβt already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 1.4.14-0 Reproducible in staging?: no Reproducible in production?: no If this was caught during regression testing, add the test name, ID and link from TestRail: n/a Email or phone of affected tester (no customers):
lizzi@infinitered.com
Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by:@lindboe Slack conversation:Action Performed:
Expected Result:
No console warnings.
Actual Result:
Console logs a warning:
I also noticed that the error eventually solves itself. If you log what the
LHNOptionsList
component is receiving, like this:You'll see the problem array in the list with a bunch of objects.
If you reload the app, you'll see the error recur, but then the surprising bit: after
LHNOptionsList
re-renders a few times (visible each time the added console.log statement prints again), eventually the empty array turns into an empty object and the problem goes away.Workaround:
Can the user still use Expensify without this being fixed? Yes, this is not noticeable to an end user.
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Video was too large for GitHub, Google drive link: https://drive.google.com/file/d/16yOTJ1n8jQHe0xyjr0Mt9mfBytWGHMw-/view?usp=drive_link (happy to host somewhere else if needed)
View all open jobs on GitHub
Upwork Automation - Do Not Edit